UNPKG

@js-ak/db-manager

Version:
58 lines (57 loc) 2.24 kB
import pg from "pg"; import { PG } from "../../index.js"; /** * Creates a new PostgreSQL client instance. * * @param config - The connection configuration as a connection string or a client configuration object. * * @returns The PostgreSQL client instance. */ export declare const createClient: (config: string | pg.ClientConfig) => pg.Client; /** * Retrieves or creates a standard connection pool. * * @param config - The database credentials configuration object. * @param [poolName="shared"] - The name suffix for the pool, default is "shared". * * @returns The retrieved or newly created standard connection pool. */ export declare const getStandardPool: (config: PG.ModelTypes.TDBCreds, poolName?: string) => pg.Pool; /** * Retrieves or creates a transaction-specific connection pool. * * @param config - The database credentials configuration object. * @param [poolName="shared"] - The name suffix for the pool, default is "shared". * * @returns The retrieved or newly created transaction connection pool. */ export declare const getTransactionPool: (config: PG.ModelTypes.TDBCreds, poolName?: string) => pg.Pool; /** * Removes and closes a standard connection pool. * * @param config - The database credentials configuration object. * @param [poolName="shared"] - The name suffix for the pool, default is "shared". * * @returns A promise that resolves when the pool is closed. */ export declare const removeStandardPool: (config: PG.ModelTypes.TDBCreds, poolName?: string) => Promise<void>; /** * Removes and closes a transaction-specific connection pool. * * @param config - The database credentials configuration object. * @param [poolName="shared"] - The name suffix for the pool, default is "shared". * * @returns A promise that resolves when the pool is closed. */ export declare const removeTransactionPool: (config: PG.ModelTypes.TDBCreds, poolName?: string) => Promise<void>; /** * Gracefully shuts down all active connection pools. * * @param options - The options object. * @param options.poolName - The pool name to match. * * @returns A promise that resolves when all pools are closed. */ export declare const shutdown: (options?: { poolName?: string; }) => Promise<void>;