inceptum
Version:
hipages take on the foundational library for enterprise-grade apps written in NodeJS
45 lines (44 loc) • 1.94 kB
TypeScript
import { Histogram, Counter, labelValues } from 'prom-client';
import { Transaction } from '../transaction/TransactionManager';
import { ConnectionPool } from './ConnectionPool';
export declare abstract class DBTransaction<C> {
protected timer: (labels?: labelValues) => void;
protected rolledBackTransactionsCounter: Counter.Internal;
protected transactionExecutionDurationsHistogram: Histogram.Internal;
protected clientName: string;
protected readonly: boolean;
protected connectionPool: ConnectionPool<C>;
protected connection: C;
protected transaction: Transaction;
protected rolledBack: boolean;
/**
*
* @param transaction
*/
constructor(clientName: string, readonly: boolean, connectionPool: ConnectionPool<C>);
/**
* Executes a query in the current connection
* @param sql The SQL to execute
* @param bindsArr the list of parameters to pass to the query, or an empty array if there are no parameters
*/
protected abstract runQueryInConnection(sql: string, bindsArr: Array<any>): Promise<any>;
runQueryWithoutTransaction(sql: string, bindsArr?: Array<any>): Promise<any>;
getTransaction(): Transaction;
begin(): Promise<void>;
private obtainConnection;
query(sql: string, ...bindArrs: any[]): Promise<any>;
queryAssoc(sql: string, bindObj: object): Promise<any>;
markError(error: any): void;
sanitizeAndRunQueryInConnection(sql: string, bindsArr?: Array<any>): Promise<any>;
runQueryAssocPrivate(sql: string, bindsObj: object): Promise<any>;
doTransactionBegin(): Promise<void>;
getTransactionBeginSQL(): string;
doTransactionCommit(): Promise<void>;
getTransactionCommitSQL(): string;
doTransactionRollback(): Promise<void>;
getTransactionRollbackSQL(): string;
releaseConnection(): Promise<void>;
end(): Promise<void>;
isRolledBack(): boolean;
isReadonly(): boolean;
}