You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 ?
The text was updated successfully, but these errors were encountered:
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 ?
The text was updated successfully, but these errors were encountered: