UNPKG

@melleb/pgtx

Version:

Simple node-postgres wrapper that abstracts transactions and savepoints

24 lines (19 loc) 715 B
import { Client } from 'pg'; declare enum TransactionStatus { ACTIVE = 0, COMMITTED = 1, CANCELLED = 2 } declare class TransactionContext { private client; private parentTransaction?; private activeSavePoint?; protected status: TransactionStatus; constructor(client: Client, parentTransaction?: TransactionContext | undefined, activeSavePoint?: string | undefined); transaction(childTransaction?: (client: PgtxClient) => Promise<void>): Promise<PgtxClient>; commit(): Promise<PgtxClient>; rollback(): Promise<PgtxClient>; } type PgtxClient = Client & TransactionContext; declare function pgtx(client: Client): PgtxClient; export { type PgtxClient, pgtx as default };