diff --git a/sequelize/sequelize.d.ts b/sequelize/sequelize.d.ts index cbfc3db18..292649c0d 100644 --- a/sequelize/sequelize.d.ts +++ b/sequelize/sequelize.d.ts @@ -5176,6 +5176,14 @@ declare module "sequelize" { */ isolationLevel? : string; + /** + * Set the default transaction type. See `Sequelize.Transaction.TRANSACTION_TYPES` for possible + * options. + * + * Defaults to 'DEFERRED' + */ + transactionType? : string; + } /** @@ -5786,6 +5794,41 @@ declare module "sequelize" { */ ISOLATION_LEVELS : TransactionIsolationLevels; + /** + * Transaction type can be set per-transaction by passing `options.type` to + * `sequelize.transaction`. Default to `DEFERRED` but you can override the default isolation level + * by passing `options.transactionType` in `new Sequelize`. + * + * The transaction types to use when starting a transaction: + * + * ```js + * { + * DEFERRED: "DEFERRED", + * IMMEDIATE: "IMMEDIATE", + * EXCLUSIVE: "EXCLUSIVE" + * } + * ``` + * + * Pass in the transaction type the first argument: + * + * ```js + * return sequelize.transaction({ + * type: Sequelize.Transaction.EXCLUSIVE + * }, function (t) { + * + * // your transactions + * + * }).then(function(result) { + * // transaction has been committed. Do something after the commit if required. + * }).catch(function(err) { + * // do something with the err. + * }); + * ``` + * + * @see TRANSACTION_TYPES + */ + TRANSACTION_TYPES : TransactionTypes; + /** * Possible options for row locking. Used in conjuction with `find` calls: * @@ -5837,6 +5880,17 @@ declare module "sequelize" { SERIALIZABLE: string; // 'SERIALIZABLE' } + /** + * Transaction type can be set per-transaction by passing `options.type` to `sequelize.transaction`. + * Default to `DEFERRED` but you can override the default isolation level by passing + * `options.transactionType` in `new Sequelize`. + */ + interface TransactionTypes { + DEFERRED: string; // 'DEFERRED' + IMMEDIATE: string; // 'IMMEDIATE' + EXCLUSIVE: string; // 'EXCLUSIVE' + } + /** * Possible options for row locking. Used in conjuction with `find` calls: */ @@ -5861,6 +5915,11 @@ declare module "sequelize" { */ isolationLevel?: string; + /** + * See `Sequelize.Transaction.TRANSACTION_TYPES` for possible options + */ + type?: string; + /** * A function that gets executed while running the query to log the sql. */