我需要向beforeUpdate添加一些条件,仅在某些属性被更新时才发送到特定事件,并且需要知道其先前的值。 我需要对象ID来执行此操作,但它不会出现在beforeUpdate值中。我怎么知道对象的ID?
beforeUpdate(values, cb) {
// if another field was updated except of the lastActive field
if (values.length > 1) {
const id = this.update.arguments[0];
// id is undefined now. how can I get user id?
const oldUser = User.findOne({id: values.id});
// because I need to know user old values in sendUser function
myFunction.sendUser(oldUser);
}
cb();
}