-
Notifications
You must be signed in to change notification settings - Fork 80
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
Pre/Post Update Hooks #59
Comments
If you're using If you're using something like If you need a temporary fix then I'd suggest using Hope this helps. |
Strange that Let say I am already have data with Thanks for all your hard work and time. |
The underlying reason it doesn't work is because Your way should work as well, as long as your What I was thinking is that your model would have been already loaded using Model.findOne({username: "me"}).then(function(m) {
m.active = false;
m.username = "you";
return m.save(); // preSave() gets called here
}).then(function(m) {
// etc...
}); Hope this helps! |
@scottwrobinson This seems to be working, thank you for the example. Still one problem I see that if you somehow adding a not existed in model's schema key, it will be added to database on
|
Can we have Pre/Post Update Hooks?
Or what is the best way to auto update
updated_at
field in model?The text was updated successfully, but these errors were encountered: