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

find{One,ById}And{Update,Remove} and save/remove hooks #1952

Closed
njoyard opened this issue Mar 9, 2014 · 2 comments
Closed

find{One,ById}And{Update,Remove} and save/remove hooks #1952

njoyard opened this issue Mar 9, 2014 · 2 comments
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature

Comments

@njoyard
Copy link
Contributor

njoyard commented Mar 9, 2014

This is more a question than an actual issue.

The documentation states that defaults, setters, validators and middleware are not applied when using one of find{One,ById}And{Update,Remove}. I'm looking into a way of at least implementing middleware calls for those methods, because the "traditional approach of first retrieving the document" is subject to race conditions.

I understand why defaults, setters, validators and pre-hooks are not applied, because it would involve parsing and changing the update operators, and possibly rolling back the changes in case validators fail (which would probably defeat those methods atomicity), although I'm sure it is not impossible (it could be done for example by using a mongoose-specific lock field, although we would have to assume mongoose is the only client updating collections).

But I don't understand why post-hooks cannot be called, as the findAndModify command tells us what have been done. Is there another reason for that ?

@xpepermint
Copy link

+1

@vkarpov15
Copy link
Collaborator

See #2138

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Projects
None yet
Development

No branches or pull requests

3 participants