gpt4 book ai didi

sails.js - sails 中有条件 beforeUpdate

转载 作者:行者123 更新时间:2023-12-01 07:55:52 33 4
gpt4 key购买 nike

仅当满足某些条件时,我才需要加密密码。

beforeUpdate: function (value, cb) {
User.findOne(value.id)
.exec(function (err, originalUser) {
if (err || !originalUser) {
return cb();
}
//encrypt the password only if the password is not previously encrypted
if (value.password != originalUser.password) {
//encrypt the Pwd
} else {
cb();
}
});

}
问题是,值对象只包含更新参数,如何在值对象中获取整个用户对象?

最佳答案

After the update of async, this method does not work anymore.



您无法在 beforeUpdate 中获取整个对象.你可以试试这个来获取id。 var id= this.update.arguments[0]

关于sails.js - sails 中有条件 beforeUpdate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27248102/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com