Sequelize托管事务未在catch块中执行回滚

时间:2017-11-03 20:30:28

标签: javascript sequelize.js bluebird

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

0 个答案:

没有答案