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')
})Discussion 0
Join free to post in the discussion.
Related questions
- Atomicity in a money transferBackend Developer
- Building SQL from user inputBackend Developer
- What atomicity guaranteesBackend Developer
- WHERE column = NULL finds nothingBackend Developer
- COUNT(*) versus COUNT(column)Backend Developer
- Column type for pricesBackend Developer
- Storing order times for two countriesBackend Developer
- Students and courses table designBackend Developer