Closed ianHeydoc closed 1 month ago
I've taken a look into the code and found this code snippet
this is on line 1212 of mongoose/lib/document.js
if (!merge) {
this.$__setValue(path, null);
cleanModifiedSubpaths(this, path);
} else {
return this.$set(val, path, constructing);
}
It looks like the merge option is lost when the second nested object is set
I've tested out adding the options to the next $set call and it looks like it works 👀
Would this be something I could open a pr to implement or is there a reason for the behaviour?
I'm new to looking at the source code for mongoose so any help would be appreciated 😃
+1
Should be fixed by #14870
Prerequisites
Mongoose version
8.6.0
Node.js version
18.15.0
MongoDB server version
NA
Typescript version (if applicable)
No response
Description
When using document set with the merge option set to true if there are multiple nested fields the deeply nested fields are ignored
Steps to Reproduce
Expected Behavior
For this code example I get
I would expect to get