UNPKG

pg-db-libs

Version:

A TypeScript library for calling PostgreSQL functions and procedures with entity mapping

19 lines (18 loc) 1.08 kB
import { ClientConfig } from "pg"; export declare class PgFunctionProcedureClient { private client; constructor(config: ClientConfig); connect(): Promise<void>; disconnect(): Promise<void>; /** * Calls a PostgreSQL function or procedure and maps the result to the specified entity type. * Handles functions/procedures with output parameters and result sets. * @param functionName The name of the function or procedure. * @param params The parameters to pass. * @param entityConstructor The constructor of the entity to map to (class). * @param {boolean} isFunction - Whether the callable is a function (true) or a procedure (false). * @param hasOutputParameters Whether the function/procedure returns output parameters. * @returns A list of entities mapped from the result or an object of output parameters. */ callFunctionOrProcedure<T extends object>(functionName: string, params: any[], entityConstructor: new () => T, isFunction?: boolean, hasOutputParameters?: boolean): Promise<T[] | Record<string, any>>; }