Skip to content
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

fix(model): deep clone bulkWrite() updateOne arguments to avoid mutating documents in update #14197

Merged
merged 6 commits into from Dec 30, 2023

Conversation

vkarpov15
Copy link
Collaborator

Summary

#14164 points out that we don't clone arguments to bulkWrite(), so Mongoose can actually end up updating documents in bulkWrite() ops.

Examples

Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me, though i am not fully sure what the code in question does

aside from that, there seem to be a bunch of unrelated empty-line removals, are those intended?

@vkarpov15
Copy link
Collaborator Author

The code in question casts the updateOne ops in a bulkWrite() call, like the following:

await Time.bulkWrite([{
  updateOne: {
    filter: { _id: timeDoc._id },
    update: { $set: timeDoc } // <-- cast this
  }
}]);

I'll undo the whitespace changes, those are unnecessary

@vkarpov15 vkarpov15 added this to the 8.0.4 milestone Dec 30, 2023
@vkarpov15 vkarpov15 merged commit d655898 into master Dec 30, 2023
34 checks passed
@hasezoey hasezoey deleted the IslandRhythms/gh-14164 branch December 30, 2023 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants