本文介绍了猫鼬中间件预更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用
schema.pre('save', function (next) {
if (this.isModified('field')) {
//do something
}
});
但是我现在需要在schema.pre('update'
挂钩中使用相同的功能isModified
,但是它不存在.有谁知道我如何在update
挂钩中使用相同的功能?
but I now need to use this same function isModified
in a schema.pre('update'
hook, but it does not exists. Does anyone know how I can use this same functionality in the update
hook?
推荐答案
根据此:
update
是查询中间件,this
引用没有isModified
方法的查询对象.
update
is query middleware and this
refers to a query object which has no isModified
method.
这篇关于猫鼬中间件预更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!