From 5e4023f1d1d64862f36fceef7597e8ae875ac442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Fily?= Date: Sat, 8 Jun 2024 14:32:07 +0200 Subject: [PATCH 1/2] Fix problem when deleting an entry on a populated Map --- lib/types/map.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/types/map.js b/lib/types/map.js index d63cd403523..dd88de8ed59 100644 --- a/lib/types/map.js +++ b/lib/types/map.js @@ -119,7 +119,7 @@ class MongooseMap extends Map { v.$__.wasPopulated = { value: v._id }; return v; }); - } else { + } else if (value) { // Fix when using delete method because the value is undefined if (value.$__ == null) { value = new populated.options[populateModelSymbol](value); } From 26ab76a51ff618a37155f6d18457c9fd699fba5e Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 10 Jun 2024 16:24:28 -0400 Subject: [PATCH 2/2] remove unnecessary comment --- lib/types/map.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/types/map.js b/lib/types/map.js index dd88de8ed59..4b8607df311 100644 --- a/lib/types/map.js +++ b/lib/types/map.js @@ -119,7 +119,7 @@ class MongooseMap extends Map { v.$__.wasPopulated = { value: v._id }; return v; }); - } else if (value) { // Fix when using delete method because the value is undefined + } else if (value != null) { if (value.$__ == null) { value = new populated.options[populateModelSymbol](value); }