UNPKG

postgrejs

Version:

Professional PostgreSQL client NodeJS

53 lines (52 loc) 2.3 kB
import { Pool as LightningPool } from 'lightning-pool'; import type { PoolConfiguration } from '../interfaces/database-connection-params.js'; import type { QueryOptions } from '../interfaces/query-options.js'; import type { QueryResult } from '../interfaces/query-result.js'; import type { ScriptExecuteOptions } from '../interfaces/script-execute-options.js'; import type { ScriptResult } from '../interfaces/script-result.js'; import type { StatementPrepareOptions } from '../interfaces/statement-prepare-options.js'; import { SafeEventEmitter } from '../safe-event-emitter.js'; import { Connection, type NotificationCallback } from './connection.js'; import { IntlConnection } from './intl-connection.js'; import type { PreparedStatement } from './prepared-statement.js'; export declare class Pool extends SafeEventEmitter { protected readonly _pool: LightningPool<IntlConnection>; protected readonly _notificationListeners: SafeEventEmitter; protected _notificationConnection?: Connection; readonly config: PoolConfiguration; constructor(config?: PoolConfiguration | string); /** * Returns number of connections that are currently acquired */ get acquiredConnections(): number; /** * Returns number of unused connections in the pool */ get idleConnections(): number; /** * Returns total number of connections in the pool regardless of whether they are idle or in use */ get totalConnections(): number; /** * Obtains a connection from the connection pool */ acquire(): Promise<Connection>; /** * Shuts down the pool and destroys all resources. */ close(terminateWait?: number): Promise<void>; /** * Executes a script */ execute(sql: string, options?: ScriptExecuteOptions): Promise<ScriptResult>; /** * Executes a query */ query(sql: string, options?: QueryOptions): Promise<QueryResult>; prepare(sql: string, options?: StatementPrepareOptions): Promise<PreparedStatement>; release(connection: Connection): Promise<void>; listen(channel: string, callback: NotificationCallback): Promise<void>; unListen(channel: string): Promise<void>; unListenAll(): Promise<void>; protected _initNotificationConnection(): Promise<void>; }