import type { Schema } from '../../../zero-schema/src/builder/schema-builder.ts';
import type { DBConnection, DBTransaction, Row } from '../../../zql/src/mutate/custom.ts';
import { Client, Pool, type PoolClient } from 'pg';
import { ZQLDatabase } from '../zql-database.ts';
/**
 * Helper type for the wrapped transaction used by node-postgres.
 *
 * @remarks Use with `ServerTransaction` as `ServerTransaction<Schema, NodePgTransaction>`.
 */
export type NodePgTransaction = Pool | PoolClient | Client;
export declare class NodePgConnection implements DBConnection<NodePgTransaction> {
    #private;
    constructor(pool: NodePgTransaction);
    transaction<TRet>(fn: (tx: DBTransaction<NodePgTransaction>) => Promise<TRet>): Promise<TRet>;
}
export declare class NodePgTransactionInternal implements DBTransaction<NodePgTransaction> {
    readonly wrappedTransaction: NodePgTransaction;
    constructor(client: NodePgTransaction);
    query(sql: string, params: unknown[]): Promise<Row[]>;
}
/**
 * Wrap a `pg` Pool for Zero ZQL.
 *
 * Provides ZQL querying plus access to the underlying node-postgres client.
 * Use {@link NodePgTransaction} to type your server mutator transaction.
 *
 * @param schema - Zero schema.
 * @param pg - `pg` Pool or connection string.
 *
 * @example
 * ```ts
 * import {Pool} from 'pg';
 *
 * const pool = new Pool({connectionString: process.env.ZERO_UPSTREAM_DB!});
 * const zql = zeroNodePg(schema, pool);
 *
 * // Define the server mutator transaction type using the helper
 * type ServerTx = ServerTransaction<
 *   Schema,
 *   NodePgTransaction
 * >;
 *
 * async function createUser(
 *   tx: ServerTx,
 *   {id, name}: {id: string; name: string},
 * ) {
 *   await tx.dbTransaction.wrappedTransaction
 *     .query('SELECT * FROM "user" WHERE id = $1', [id]);
 * }
 * ```
 */
export declare function zeroNodePg<S extends Schema>(schema: S, pg: NodePgTransaction | string): ZQLDatabase<S, NodePgTransaction>;
//# sourceMappingURL=pg.d.ts.map