node.js - mongoose middleware pre update -
i using
schema.pre('save', function (next) { if (this.ismodified('field')) { //do } }); but need use same function ismodified in schema.pre('update' hook, not exists. know how can use same functionality in update hook?
not possible according this:
query middleware differs document middleware in subtle important way: in document middleware, refers document being updated. in query middleware, mongoose doesn't have reference document being updated, refers query object rather document being updated.
update query middleware , this refers query object has no ismodified method.
Comments
Post a Comment