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

Add clarification about overwrite flag in model.js #12447

Merged
merged 3 commits into from Sep 22, 2022

Conversation

Tzvika-m
Copy link
Contributor

Add calrification for using the overwrite flag in model.findByIdAndUpdate and model.findOneAndUpdate

Summary

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.

Add calrification for using the `overwrite` flag in model.findByIdAndUpdate and model.findOneAndUpdate
@Uzlopak Uzlopak changed the title Add calrification about overwrite flag in model.js Add clarification about overwrite flag in model.js Sep 20, 2022
Copy link
Collaborator

@Uzlopak Uzlopak left a 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".

@Tzvika-m
Copy link
Contributor Author

@Uzlopak What did you have in mind?

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.

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

lib/model.js Outdated Show resolved Hide resolved
lib/model.js Outdated Show resolved Hide resolved
@Uzlopak Uzlopak self-requested a review September 22, 2022 08:28
Copy link
Collaborator

@Uzlopak Uzlopak left a 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

Tzvika-m and others added 2 commits September 22, 2022 13:26
Co-authored-by: hasezoey <hasezoey@gmail.com>
Co-authored-by: hasezoey <hasezoey@gmail.com>
@Tzvika-m
Copy link
Contributor Author

Great, thanks
I've committed your suggestions @hasezoey

@hasezoey hasezoey merged commit 69c99d2 into Automattic:master Sep 22, 2022
@hasezoey hasezoey added this to the 6.6.2 milestone Sep 22, 2022
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