UNPKG

queryforge

Version:

A powerful, type-safe SQL query builder for Node.js with support for MySQL, PostgreSQL, and SQLite. Features fluent API, transaction management, and connection pooling.

46 lines (45 loc) 1.67 kB
import { QueryOptions } from './interfaces'; import { WhereCondition, JoinCondition, OrderDirection } from './types'; interface QueryState { type: 'SELECT' | 'INSERT' | 'UPDATE' | 'DELETE'; table: string; columns: string[]; values: any[]; where: WhereCondition[]; joins: JoinCondition[]; groupBy: string[]; having: WhereCondition[]; orderBy: { column: string; direction: OrderDirection; }[]; limit?: number; offset?: number; updateValues?: Record<string, any>; } export declare class QueryBuilder { protected state: QueryState; protected options: QueryOptions; constructor(options?: QueryOptions); protected reset(keepTable?: boolean): void; table(tableName: string): this; select(...columns: string[]): this; where(column: string, operator: string, value: any): this; orWhere(column: string, operator: string, value: any): this; join(table: string, leftColumn: string, operator: string, rightColumn: string): this; leftJoin(table: string, leftColumn: string, operator: string, rightColumn: string): this; orderBy(column: string, direction?: OrderDirection): this; groupBy(...columns: string[]): this; having(column: string, operator: string, value: any): this; limit(limit: number): this; offset(offset: number): this; insert(data: Record<string, any>): this; insertMany(records: Record<string, any>[]): this; update(data: Record<string, any>): this; delete(): this; getState(): QueryState; protected buildQuery(): string; protected buildParameters(): any[]; execute<T = any>(): Promise<T[]>; } export {};