import { Dialect } from './Dialect'; import { SqlResult } from '../models/SqlResult'; import { ResultSet, Row } from '../result/ResultSet'; /** Minimal client shape QueryBuilder needs to dispatch via `.run()`. */ export interface RunnableClient { dialect: Dialect; query(sql: string, params?: unknown[]): Promise>; execute(sql: string, params?: unknown[]): Promise; } /** * Fluent SQL builder that compiles to a parametrised `{ text, values }`. * Never executes on its own — call `.toSql()` to hand the statement to a raw * call, or `.run(client)` to dispatch through a client. */ export declare class QueryBuilder { private kind; private table; private _columns; private _joins; private _wheres; private _groupBy; private _having; private _orderBy; private _limit?; private _offset?; private _insertRows; private _setRow?; private _returning?; private constructor(); static select(table: string): QueryBuilder; static insert(table: string): QueryBuilder; static update(table: string): QueryBuilder; static delete(table: string): QueryBuilder; columns(...cols: string[]): this; join(table: string, on: string): this; where(clause: string, ...params: unknown[]): this; whereIn(col: string, values: unknown[]): this; whereNull(col: string): this; whereNotNull(col: string): this; groupBy(...cols: string[]): this; having(clause: string, ...params: unknown[]): this; orderBy(col: string, dir?: 'asc' | 'desc'): this; limit(n: number): this; offset(n: number): this; /** Add row(s) to insert. Repeated calls (or an array) accumulate into a multi-row INSERT. */ values(row: Record | Record[]): this; set(row: Record): this; /** Make the write return rows (RETURNING / OUTPUT). No args → all columns. */ returning(...cols: string[]): this; /** Quote a column reference: per-segment for dotted names, raw for expressions. */ private quoteColumn; /** Replace `?` markers in a fragment with dialect placeholders, threading the counter. */ private renderFragment; toSql(dialect: Dialect): { text: string; values: unknown[]; }; private buildWhere; private buildSelect; /** Compile the RETURNING/OUTPUT clause if requested, else undefined. */ private compileReturning; private buildInsert; private buildUpdate; private buildDelete; /** Dispatch through a client: SELECT and row-returning writes → query, everything else → execute. */ run>(client: RunnableClient): Promise>; /** run() + rows(): dispatch and wrap straight into a ResultSet. */ fetch>(client: RunnableClient): Promise>; one>(client: RunnableClient): Promise>; maybeOne>(client: RunnableClient): Promise | undefined>; scalar(client: RunnableClient, column?: string): Promise; /** SELECT COUNT(*) honouring only the WHERE clauses. Number()-coerced (postgres returns string). */ count(client: RunnableClient): Promise; exists(client: RunnableClient): Promise; }