我有一个属性模型:status
和statusId
状态可以是:
StatusId和Status描述如下:
我想要的是如果我插入或更新我的模型的状态,那么statusId应该相应地自动更新。
您可以使用两件事来实现此方案
Observe
为该模型使用Remote钩子<model>.observe('before save', function (ctx, next) {
// check the ctx and add the necessary validations
}
app.remotes().before('**', (ctx, next) => {
// do stuff with ctx.args.options
next();
});