Different behaviour with set() when using subdocuments #9046
Labels
docs
This issue is due to a mistake or omission in the mongoosejs.com documentation
Milestone
I noticed a different behavior of
set()
when using a sub-schema vs using just a more nested schema. Until now, I had assumed that except for the added_id
property, using one of the other was pretty much equivalent and just opened more flexibility when using a sub-schema. Am I wrong to assume that?Anyway, after moving a "location" field to a sub-schema (
LocationSchema
in the following repro code), I notice a different behaviour when using.set()
with a Document which already has some data in these paths.Without the subschema, it appears to "merge" the nested props, but with the subschema it replaces the whole path with the new one.
Is that documented somewhere? Is that a bug?
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Mongoose 5.9.8 and also tested on 4.13.19. Node 8.
The text was updated successfully, but these errors were encountered: