-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[Bug] Model.bulkWrite wipes all the document data if no update provided #8331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
AbdelrahmanHafez
added a commit
to AbdelrahmanHafez/mongoose
that referenced
this issue
Nov 13, 2019
vkarpov15
added a commit
that referenced
this issue
Nov 13, 2019
AbdelrahmanHafez
added a commit
to AbdelrahmanHafez/mongoose
that referenced
this issue
Mar 20, 2020
vkarpov15
added a commit
that referenced
this issue
Mar 20, 2020
refactor(model.test): prevent false positive in #8331 test
This was referenced Mar 15, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If we for some reason (mostly by mistake) did not provide an
update
object inupdateOne
orupdateMany
operation in Model.bulkWrite, it wipes all the data inside the document except for the_id
field.Here's a test reproducing the issue.
What is the expected behavior?
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
This usually happens when a developer is inserting an
update
object off by one curly brace, which is fairly easy to miss:The expected behavior: for bulkWrite to throw an error instead of just wiping all the data inside the documents .
The text was updated successfully, but these errors were encountered: