@breautek/storm
Version:
Object-Oriented REST API framework
32 lines (31 loc) • 1.53 kB
TypeScript
import { IDatabaseConnection } from './IDatabaseConnection';
import { IQueryable } from './IQueryable';
import { Application } from './Application';
import { IsolationLevel } from './IsolationLevel';
import { TransactionAccessLevel } from './TransactionAccessLevel';
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;
private $accessLevel;
constructor(app: Application, executor: ITransactionExecutor, retryLimit?: number, isolationLevel?: IsolationLevel, accessLevel?: TransactionAccessLevel);
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>;
}