From df4f1c55f016ba738a5f13e59c8db42960bf9789 Mon Sep 17 00:00:00 2001 From: DevDrizzy Date: Sun, 17 Mar 2024 19:13:23 +0500 Subject: [PATCH] Fixed deleteKeyInAll logic Signed-off-by: DevDrizzy --- src/main/java/xyz/refinedev/api/storage/MongoStorage.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/xyz/refinedev/api/storage/MongoStorage.java b/src/main/java/xyz/refinedev/api/storage/MongoStorage.java index 4f4c380..669b522 100644 --- a/src/main/java/xyz/refinedev/api/storage/MongoStorage.java +++ b/src/main/java/xyz/refinedev/api/storage/MongoStorage.java @@ -123,8 +123,11 @@ public CompletableFuture deleteKeyInAll(String key) { for ( Document document : collection.find() ) { if (document == null) continue; - document.remove(key); - deleteCount++; + if (document.get(key) != null) { + document.remove(key); + deleteCount++; + } + collection.replaceOne(Filters.eq("_id", document.get("_id")), document); } return deleteCount; });