Concurrent/Partial transactions

You can have concurrent transactions within a sequence of queries or have some of them excluded from any transactions. Use the {transaction: } option to control which transaction a query belong to:

Warning:SQLite does not support more than one transaction at the same time.

Without CLS enabled

  1. sequelize.transaction((t1) => {
  2. return sequelize.transaction((t2) => {
  3. // With CLS enable, queries here will by default use t2
  4. // Pass in the `transaction` option to define/alter the transaction they belong to.
  5. return Promise.all([
  6. User.create({ name: 'Bob' }, { transaction: null }),
  7. User.create({ name: 'Mallory' }, { transaction: t1 }),
  8. User.create({ name: 'John' }) // this would default to t2
  9. ]);
  10. });
  11. });