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
Add clarification about overwrite flag in model.js #12447
Conversation
Add calrification for using the `overwrite` flag in model.findByIdAndUpdate and model.findOneAndUpdate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me this change has no additional value as it just says see overwrite. It should have more than "see overwrite".
@Uzlopak What did you have in mind? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, i think it helps having a note to the option to prevent the automatic extra behavior form happening (if the option exists) in the example itself
some small things to suggest to keep the naming more consistent
Edit: i think the option itself should maybe be renamed instead of just overwrite
to something like originalBehavior
or noSet
or noAutoSet
or something along these lines, but this would be a breaking change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I follow in this case @hasezoey
Co-authored-by: hasezoey <hasezoey@gmail.com>
Co-authored-by: hasezoey <hasezoey@gmail.com>
Great, thanks |
Add calrification for using the
overwrite
flag in model.findByIdAndUpdate and model.findOneAndUpdateSummary
The way mongoose changes the update behaviour (adds
$set
to the update command) and how to prevent it is not intirely clear.I believe this note could help save some time and effort for future users.