2017-08-30 5 views

答えて

1
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

を文書化されて

関連する問題