gpt4 book ai didi

node.js - sequelize beforeValidate 将键和值放入对象

转载 作者:行者123 更新时间:2023-12-03 22:42:49 24 4
gpt4 key购买 nike

我正在尝试从 beforeUpdate Hook 中的 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() 是正确的功能吗?

最佳答案

愚蠢应该受到惩罚;)

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)
})

}

关于node.js - sequelize beforeValidate 将键和值放入对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28064046/

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