Isolation levels

The possible isolations levels to use when starting a transaction:

  1. Sequelize.Transaction.ISOLATION_LEVELS.READ_UNCOMMITTED // "READ UNCOMMITTED"
  2. Sequelize.Transaction.ISOLATION_LEVELS.READ_COMMITTED // "READ COMMITTED"
  3. Sequelize.Transaction.ISOLATION_LEVELS.REPEATABLE_READ // "REPEATABLE READ"
  4. Sequelize.Transaction.ISOLATION_LEVELS.SERIALIZABLE // "SERIALIZABLE"

By default, sequelize uses the isolation level of the database. If you want to use a different isolation level, pass in the desired level as the first argument:

  1. return sequelize.transaction({
  2. isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.SERIALIZABLE
  3. }, (t) => {
  4. // your transactions
  5. });

The isolationLevel can either be set globally when initializing the Sequelize instance orlocally for every transaction:

  1. // globally
  2. new Sequelize('db', 'user', 'pw', {
  3. isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.SERIALIZABLE
  4. });
  5. // locally
  6. sequelize.transaction({
  7. isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.SERIALIZABLE
  8. });

Note:The SET ISOLATION LEVEL queries are not logged in case of MSSQL as the specified isolationLevel is passed directly to tedious