我天~transaction有这么多种写法谁记得住啊
来源:9-4 LinValidator的alias别名_01

学东西要快
2019-05-30
就这节课里包含的就有三种写法
一是
Favor.create({...}, {transaction: t})
二是
art.increment('fav_nums', {by: 1, transaction: t})
三是
favor.destroy({force: true, transaction: t})
这实在记不灵清
sequelize难道不能主动生成事务
然后把sql操作写在try catch里面, 在catch里面回滚吗?
譬如
try {
const t = sequelize.createTransaction()
await create()
await delete()
await update()
await search()
t.commit()
} catch(e) {
t.rollback()
}
写回答
1回答
-
我看了很多次文档,没有这种写法。
022019-06-01
相似问题