Skip to content
RED SAGSkills
medium10 pts · first answer countsdatabasesormtransactions

One query escapes the transaction

In this Sequelize code, the stock update stays even when the transaction rolls back. Why?

await sequelize.transaction(async (t) => {
  await Order.create(data, { transaction: t })
  await Product.decrement('stock', { where: { id } })
  throw new Error('payment failed')
})
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions