Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to pass sequelize transaction to save method

models.sequelize.transaction(function (t) {

return models.Banks.findOne({where: {
       money: {
         $gt: 0
       }
    }, lock: t.LOCK.UPDATE, transaction: t }).then(function(bank){

    bank.money -= amountToWithdraw;
    return bank.save({transaction: t});
  })
})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pass #sequelize #transaction #save #method
ADD COMMENT
Topic
Name
3+9 =