You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The fundamental issue here is that, in Mongoose 6, findOneAndUpdate() with overwrite: true executes a findOneAndReplace(). We'll add that behavior back to Mongoose 7, but I would recommend you use findOneAndReplace() instead of findOneAndUpdate() with overwrite. We may deprecate the overwrite option in the future.
vkarpov15
added
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
and removed
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
labels
Jul 3, 2023
Prerequisites
Mongoose version
7.x
Node.js version
18.15
MongoDB server version
6.x
Typescript version (if applicable)
5.1.3
Description
The
.toObject()
method called after the creation of a document has a different behavior when you compare mongoose version 6.x and 7.xIt looks like the deeply nested properties , when set to undefined, and passed to a
findByIdAndUpdate
in:null
removing the
toObject()
method call make the 2 mongoose versions behave the same way, as displayed in the steps to ReproduceSteps to Reproduce
These are the logs for version 6.x with the

toObject()
method call:These are the logs for version 7.x with the

toObject()
method call:These are the logs for version 7.x without the

toObject()
method call:Expected Behavior
No response
The text was updated successfully, but these errors were encountered: