32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { Pool, PoolClient, QueryResult, QueryResultRow } from 'pg';
|
|
import { TxnOption } from 'oak-domain/lib/types';
|
|
import { PostgreSQLConfiguration } from './types/Configuration';
|
|
export declare class PostgreSQLConnector {
|
|
pool: Pool;
|
|
configuration: PostgreSQLConfiguration;
|
|
txnDict: Record<string, PoolClient>;
|
|
constructor(configuration: PostgreSQLConfiguration);
|
|
connect(): void;
|
|
disconnect(): Promise<void>;
|
|
startTransaction(option?: TxnOption): Promise<string>;
|
|
/**
|
|
* 映射隔离级别到 PostgreSQL 语法
|
|
*/
|
|
private mapIsolationLevel;
|
|
exec(sql: string, txn?: string): Promise<[QueryResultRow[], QueryResult]>;
|
|
commitTransaction(txn: string): Promise<void>;
|
|
rollbackTransaction(txn: string): Promise<void>;
|
|
/**
|
|
* 执行多条 SQL 语句(用于初始化等场景)
|
|
*/
|
|
execBatch(sqls: string[], txn?: string): Promise<void>;
|
|
/**
|
|
* 获取连接池状态
|
|
*/
|
|
getPoolStatus(): {
|
|
total: number;
|
|
idle: number;
|
|
waiting: number;
|
|
};
|
|
}
|