-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Model.bulkSave() and setting the query with "save" and "bulkWrite" pre middleware causes path conflict #14722
Closed
1 task done
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Comments
blowfishlol
added
help
This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary
help wanted
labels
Jul 3, 2024
vkarpov15
added
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
and removed
help
This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary
help wanted
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
labels
Jul 4, 2024
The fundamental issue here is that |
vkarpov15
added a commit
that referenced
this issue
Jul 5, 2024
vkarpov15
added a commit
that referenced
this issue
Jul 9, 2024
vkarpov15
added a commit
that referenced
this issue
Jul 9, 2024
Avoid leaving subdoc defaults on top-level doc when setting subdocument to same value
This was referenced Aug 2, 2024
This was referenced Sep 4, 2024
This was referenced Sep 11, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Mongoose version
8.4.4
Node.js version
18.19.0
MongoDB version
6.0.15 Community
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
14.4.1 (23E224)
Issue
I have the following code that have both save and bulkWrite pre-hooks installed to a schema:
In the example above, i will get an error:
This happens because in the
bulkWrite
pre-hook, im assigning$set.updater
asgetUser()
when theop
already containsupdatedBy._id
, which is set by the "save" hook:After the
save
prehook, before thebulkWrite
prehookAnd after the the
bulkWrite
prehook is doneIs there any i can stop the
bulkWrite
hook from firing if i save usingbulkSave()
? Im awarebulkSave
will fire bothsave
and usesbulkWrite
under the hood.Or i should just do a check in the
bulkWrite
middleware to see if theops
already contains theupdater._id
?Other thing that i realised when testing around is that adding _id explicitly into the
updateInfoSchema
will not cause this issue, since theops
inside thebulkWrite
prehook does not contain the udpate toupdater._id
The text was updated successfully, but these errors were encountered: