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

Method begin

packages/core/src/EntityManager.ts:1697–1707  ·  view source on GitHub ↗

* Starts new transaction bound to this EntityManager. Use `ctx` parameter to provide the parent when nesting transactions.

(options: Omit<TransactionOptions, 'ignoreNestedTransactions'> = {})

Source from the content-addressed store, hash-verified

1695 * Starts new transaction bound to this EntityManager. Use `ctx` parameter to provide the parent when nesting transactions.
1696 */
1697 async begin(options: Omit<TransactionOptions, 'ignoreNestedTransactions'> = {}): Promise<void> {
1698 if (this.#disableTransactions) {
1699 return;
1700 }
1701
1702 const em = this.getContext(false);
1703 em.#transactionContext = await em.getConnection('write').begin({
1704 ...options,
1705 eventBroadcaster: new TransactionEventBroadcaster(em, { topLevelTransaction: !options.ctx }),
1706 });
1707 }
1708
1709 /**
1710 * Commits the transaction bound to this EntityManager. Flushes before doing the actual commit query.

Calls 2

getContextMethod · 0.95
getConnectionMethod · 0.65

Tested by

no test coverage detected