Closed hengkiardo closed 10 years ago
It's actually impossible to hook middleware onto update
, findByIdAndUpdate
, findOneAndUpdate
, findOneAndRemove
and findByIdAndRemove
in Mongoose at the moment.
This means that no plugin is actually run when using any of these functions.
Check out the notes section in the Mongoose documentation for middleware. Issue LearnBoost/mongoose#964 also describes this.
You could do this instead:
User.findById(id).exec().then(function(user) {
user.last_login = new Date();
user.save();
});
any idea what was causing this (dates not updating on "update" command)? I'm getting this too...
Why this is closed? It is actually a huge issue developers facing right now
when i do update to docement, field
updatedAt
not updated with current Date time. example my query