import { Condition } from './conditions'; import { TableSchema } from '../schema/table-builder'; import type { DatabaseClient } from '../database/database-client.interface'; import type { OrderDirection } from '../entity/db-context'; import { QueryExecutor } from '../entity/db-context'; /** * Join type */ export type JoinType = 'INNER' | 'LEFT'; /** * Join definition */ export interface JoinDefinition { type: JoinType; table: string; alias: string; schema: TableSchema; condition: Condition; } /** * Query context for join queries */ export interface JoinQueryContext { paramCounter: number; allParams: any[]; } /** * Join query builder with strong typing for joined tables */ export declare class JoinQueryBuilder { private leftSchema; private leftAlias; private rightSchema; private rightAlias; private joinType; private joinCondition; private client; private joins; private selection?; private whereCond?; private limitValue?; private offsetValue?; private orderByFields; private executor?; constructor(leftSchema: TableSchema, leftAlias: string, rightSchema: TableSchema, rightAlias: string, joinType: JoinType, joinCondition: Condition, client: DatabaseClient, executor?: QueryExecutor); /** * Override the timeout for this join query (ms). Only this query is wrapped * (`SET LOCAL statement_timeout`). Overrides the connection-level default; pass * `0` to disable. On timeout a `QueryTimeoutError` is thrown. */ withTimeout(timeoutMs: number): this; /** * Mark this join query as expected to finish within `expectedMs` (ms). If it * runs longer, the context's `onQueryTakingTooLong` callback fires (the query * is NOT cancelled). Overrides the context's `longRunningQueryThreshold`. */ expectedExecutionTime(expectedMs: number): this; /** * Add another left join */ leftJoin(rightTable: { _schema: TableSchema; _alias: string; }, condition: (left: TLeft, right: TRight, third: TThird) => Condition, selector: (left: TLeft, right: TRight, third: TThird) => any): any; /** * Add another inner join */ innerJoin(rightTable: { _schema: TableSchema; _alias: string; }, condition: (left: TLeft, right: TRight, third: TThird) => Condition, selector: (left: TLeft, right: TRight, third: TThird) => any): any; /** * Add WHERE condition * Multiple where() calls are chained with AND logic */ where(condition: (left: TLeft, right: TRight) => Condition): this; /** * Limit results */ limit(count: number): this; /** * Offset results */ offset(count: number): this; /** * Order by field(s) from joined tables * @example * .orderBy((l, r) => l.colName) * .orderBy((l, r) => [l.colName, r.otherCol]) * .orderBy((l, r) => [[l.colName, 'ASC'], [r.otherCol, 'DESC']]) */ orderBy(selector: (left: TLeft, right: TRight) => T): this; orderBy(selector: (left: TLeft, right: TRight) => T[]): this; orderBy(selector: (left: TLeft, right: TRight) => Array<[T, OrderDirection]>): this; /** * Execute query and return results */ toList(): Promise; /** * Execute query and return first result or null */ first(): Promise; /** * Execute query and return first result or throw */ firstOrThrow(): Promise; /** * Set the selection (called internally) */ _setSelection(selector: (left: TLeft, right: TRight) => any): void; /** * Create mock row for a table */ private createMockRow; /** * Build SQL query for the join */ private buildQuery; } //# sourceMappingURL=join-builder.d.ts.map