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

findAndUpdate: change the default new to true by default on mongoose? #9184

Closed
AbdelrahmanHafez opened this issue Jun 27, 2020 · 2 comments
Closed
Labels
discussion If you have any thoughts or comments on this issue, please share them!

Comments

@AbdelrahmanHafez
Copy link
Collaborator

We could introduce a breaking change in 6.0 and make findOneAndUpdate have new option set to true by default, after implementing #9183 we will be giving users the option to change that behavior if they prefer.

I believe the majority of users would prefer to have the updated document returned from findOneAndUpdate by default.

Thoughts? @vkarpov15

@AbdelrahmanHafez AbdelrahmanHafez added backwards-breaking discussion If you have any thoughts or comments on this issue, please share them! labels Jun 27, 2020
@AbdelrahmanHafez AbdelrahmanHafez added this to the 6.0 milestone Jun 27, 2020
@vkarpov15
Copy link
Collaborator

We changed new to false by default in 4.0 to be consistent with the MongoDB driver - all other MDB clients use new: false behavior by default, so I think we should err on the side of keeping it consistent. I like the idea of making it a globally configurable default like you suggested in #9183 though.

@AbdelrahmanHafez
Copy link
Collaborator Author

Ah, weird default from MongoDB, never seen a single findOneAndUpdate(...) out there that wasn't using { new: true } unless it was missing by mistake.

IMO, it's more intuitive to have new: true by default, but I agree that we should be consistent with the MongoDB driver as long as we can globally configure it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion If you have any thoughts or comments on this issue, please share them!
Projects
None yet
Development

No branches or pull requests

2 participants