Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


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

njoyard opened this Issue · 2 comments

3 participants


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 ?


See #2138

@vkarpov15 vkarpov15 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.