user.setShooter 会在这里做什么?
return sequelize.transaction(function (t) {
// chain all your queries here. make sure you return them. <br>
return User.create({<br>
firstName: 'Abraham',<br>
lastName: 'Lincoln'<br>
}, {transaction: t}).then(function (user) {<br>
return user.setShooter({<br>
firstName: 'John',<br>
lastName: 'Boothe'<br>
}, {transaction: t});<br>
});<br>
<br>
}).then(function (result) {<br>
// Transaction has been committed<br>
// result is whatever the result of the promise chain returned to the transaction callback<br>
}).catch(function (err) {<br>
// Transaction has been rolled back<br>
// err is whatever rejected the promise chain returned to the transaction callback<br>
});<br>
最佳答案
setShooter 只不过是某个 Sequelize 模型类中的一个函数
例如
import Sequelize from 'sequelize'
export default class Product extends Sequelize.Model {
// model init
static init(sequelize) {
return super.init({
name: { type: Sequelize.STRING(128), allowNull: false },
description: { type: Sequelize.TEXT, allowNull: false }
},
{
sequelize,
tableName: 'c_products'
})
}
setShooter() {
console.log('Hello World!')
}
}
关于node.js - sequelize 交易中的 setShooter 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51308700/