MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / transactional

Method transactional

packages/core/src/EntityManager.ts:1683–1692  ·  view source on GitHub ↗

* 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 = {})

Source from the content-addressed store, hash-verified

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.

Callers 15

rollupFunction · 0.45
runMigrationsFunction · 0.45
processTransactionMethod · 0.45
doCommitMethod · 0.45
TransactionalFunction · 0.45
TransactionalFunction · 0.45
Connection.test.tsFile · 0.45

Calls 2

getContextMethod · 0.95
handleMethod · 0.95

Tested by 2

workFunction · 0.36
workFunction · 0.36