UNPKG

@breautek/storm

Version:

Object-Oriented REST API framework

30 lines (29 loc) 1.4 kB
import { IDatabaseConnection } from './IDatabaseConnection'; import { IQueryable } from './IQueryable'; import { Application } from './Application'; import { IsolationLevel } from './IsolationLevel'; export type ITransactionExecutor = (connection: IDatabaseConnection) => Promise<void>; /** * A class encapsulating an entire transaction from beginning to commitment. * * This encapsulates a routine to conduct for the transaction. * Should the transaction fail due to a deadlock, the transaction will automatically * be tried. * * NOTE: It is unsafe to run two transactions on the same connection concurrently. * The execution *must* be waited to complete before executing another transaction, * on the same connection. */ export declare class Transaction implements IQueryable<void> { private $retryLimit; private $application; private $isolationLevel; private $executor; constructor(app: Application, executor: ITransactionExecutor, retryLimit?: number, isolationLevel?: IsolationLevel); onPreQuery(connection: IDatabaseConnection): Promise<void>; onPostQuery(connection: IDatabaseConnection): Promise<void>; getQuery(connection: IDatabaseConnection): string; getParametersForQuery(): Record<string, any>; onPostProcess(connection: IDatabaseConnection, results: any): Promise<void>; execute(connection: IDatabaseConnection): Promise<void>; }