トランザクションのSequelize docsから得た以下の例では、クエリとトランザクション後処理メソッドのreturn文を追加する必要がある理由がわかりません。関数内のreturn文
function doTransaction() {
return sequelize.transaction(function (t) {
// chain all your queries here. make sure you return them.
return User.create({
firstName: 'Abraham',
lastName: 'Lincoln'
}, {transaction: t}).then(function (user) {
return user.setShooter({
firstName: 'John',
lastName: 'Boothe'
}, {transaction: t});
});
}).then(function (result) {
// Transaction has been committed
// result is whatever the result of the promise chain returned to the transaction callback
}).catch(function (err) {
// Transaction has been rolled back
// err is whatever rejected the promise chain returned to the transaction callback
});
}
hmm私は、あなたが言っていることを理解しているかどうかわからない、私は最初のものと無関係と思われるので投稿した2番目の例を取り除くつもりです – lboyel
約束を「返す」ことができないと約束チェーンは、待っている。あなたが何かを返すなら、それは待つ義務があります。 – tadman