0
sequelize
にモデルが変更されているかどうかを確認する方法はありますか?例えば汚れたモデルを続ける
sequelize
にモデルが変更されているかどうかを確認する方法はありますか?例えば汚れたモデルを続ける
var user = User.findOne(where:{email:'[email protected]'}).then(user=>{
if(some_condition)user.email = '[email protected]'
//can I do something like this to check if model has been changed? before the save action?
if(user.dirty){}
})
Sequelizeは、モデルインスタンスレベルで変更方法を持っている、しかし、これは_previousDataValues
と電流値とを比較します。
そのそれは
Model.testModel.findById(23)
.then(instance => {
instance.name = "new Name";
console.log(instance.changed());
// This should log [name] and would be false if nothing was changed.
})
として使用することができ
here
を文書化されて