-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
isNew or isModified() for post hooks #2162
Comments
See #1474 and http://stackoverflow.com/questions/17099025/determine-whether-doc-is-new-or-exists-in-mongoose-post-middlewares-save . Long story short, you can do this yourself pretty easily by recording the value of |
This is pretty insane. Can't understand why not to put this logic inside mongoose. |
I agree with @ericsaboia |
As far as I understand it, this is trickier than its worth. Post save hooks are run after the save function, so there's no way to clean up internal state like |
For
pre('save')
middleware there is isNew/isModified to figure out if the document is new. I couldn't find something similar forpost('save')
. I am wondering is there something similar forpost('save')
?The text was updated successfully, but these errors were encountered: