@starbemtech/star-db-query-builder
Version:
A query builder to be used with mysql or postgres
26 lines (25 loc) • 1.19 kB
TypeScript
import { Pool, PoolConfig } from 'pg';
import { IDatabaseClient } from './IDatabaseClient';
import { RetryOptions } from '../core/types';
/**
* Creates a PostgreSQL database client
*
* This function initializes a PostgreSQL database client with the provided pool configuration
* and optional retry options. It sets up monitoring for connection events and query operations.
*
* @param pool - The PostgreSQL pool instance
* @param retryOptions - Optional retry options for failed queries
* @param poolConfig - Optional pool configuration
* @param installUnaccentExtension - Optional flag to install unaccent extension
* @returns IDatabaseClient - The PostgreSQL database client instance
*
* @example
* const pgClient = await createPgClient(pool, { retries: 3, factor: 2, minTimeout: 1000 });
*
* @example
* const pgClient = await createPgClient(pool, { retries: 3, factor: 2, minTimeout: 1000 });
*
* @example
* const pgClient = await createPgClient(pool, { retries: 3, factor: 2, minTimeout: 1000 });
*/
export declare const createPgClient: (pool: Pool, retryOptions?: RetryOptions, poolConfig?: PoolConfig, installUnaccentExtension?: boolean) => Promise<IDatabaseClient>;