(
options: {
isolationLevel?: IsolationLevel;
ctx?: ClientSession;
eventBroadcaster?: TransactionEventBroadcaster;
} & TransactionOptions = {},
)
| 410 | } |
| 411 | |
| 412 | override async begin( |
| 413 | options: { |
| 414 | isolationLevel?: IsolationLevel; |
| 415 | ctx?: ClientSession; |
| 416 | eventBroadcaster?: TransactionEventBroadcaster; |
| 417 | } & TransactionOptions = {}, |
| 418 | ): Promise<ClientSession> { |
| 419 | await this.ensureConnection(); |
| 420 | const { ctx, isolationLevel, eventBroadcaster, ...txOptions } = options; |
| 421 | |
| 422 | if (!ctx) { |
| 423 | await eventBroadcaster?.dispatchEvent(EventType.beforeTransactionStart); |
| 424 | } |
| 425 | const session = ctx || this.getClient().startSession(); |
| 426 | session.startTransaction(txOptions); |
| 427 | this.logQuery('db.begin();'); |
| 428 | await eventBroadcaster?.dispatchEvent(EventType.afterTransactionStart, session); |
| 429 | |
| 430 | return session; |
| 431 | } |
| 432 | |
| 433 | override async commit(ctx: ClientSession, eventBroadcaster?: TransactionEventBroadcaster): Promise<void> { |
| 434 | await this.ensureConnection(); |
no test coverage detected