我试图从beforeUpdate挂钩中的sequelize模型中获取所有字段及其对应的值,但我无法弄清楚我的错误
,{
timestamps: false,
underscored: true,
hooks: {
beforeValidate: function(transaction, options, fn) {
var ObjectToHash = transaction.getDataValue(); // Here I'm trying to get only the fields and their values
makehash(ObjectToHash)
.then(function(res){
transaction.hash = res;
fn(null, transaction)
})
}
}
}
是getDataValue()的正确功能吗?
答案 0 :(得分:0)
愚蠢应该受到惩罚;)
beforeValidate: function(transaction, options, fn) {
console.log('beforeCreate hook')
var ObjectToHash = transaction.get();
console.log(ObjectToHash)
makehash(ObjectToHash)
.then(function(res){
console.log('hash created for: '+transaction.id)
transaction.hash = res;
fn(null, transaction)
})
}