使用sequelize托管事务我想在catch块中回滚空结果错误
const supplier=req.body;
return models.sequelize.transaction({autocommit:false},(t) => {
return Promise.props({
'terms': models.Terms.findOne({ 'where': { 'name': supplier.terms },transaction: t, 'rejectOnEmpty': true }),
'currencies': models.Currencies.findOne({ 'where': { 'currencyCode': supplier.currencyCode },transaction: t, 'rejectOnEmpty': true }),
'keywords': Promise.map(supplier.keywords, (keywordString) => {
return models.Keywords.findOrCreate({ where: { keyword: keywordString }, defaults: { keyword: keywordString }, transaction: t })
}
)
})
}).then((result)=>{
console.log("good")
})
.catch(models.sequelize.EmptyResultError, (err) => {
//should rollback here. but not rolling back
})