* Runs your callback wrapped inside a database transaction. * * If a transaction is already active, a new savepoint (nested transaction) will be created by default. This behavior * can be controlled via the `propagation` option. Use the provided EntityManager instance for all operations tha
(cb: (em: this) => T | Promise<T>, options: TransactionOptions = {})
| 1681 | * ``` |
| 1682 | */ |
| 1683 | async transactional<T>(cb: (em: this) => T | Promise<T>, options: TransactionOptions = {}): Promise<T> { |
| 1684 | const em = this.getContext(false); |
| 1685 | |
| 1686 | if (this.#disableTransactions || em.#disableTransactions) { |
| 1687 | return cb(em); |
| 1688 | } |
| 1689 | |
| 1690 | const manager = new TransactionManager(this); |
| 1691 | return manager.handle(cb as (em: EntityManager) => T | Promise<T>, options); |
| 1692 | } |
| 1693 | |
| 1694 | /** |
| 1695 | * Starts new transaction bound to this EntityManager. Use `ctx` parameter to provide the parent when nesting transactions. |