/** * Unified Statement Interface * * Wraps database-specific prepared statements to provide consistent API * Compatible with better-sqlite3 and pg * * @module statement */ /** * Run result from statement execution */ export interface RunResult { changes: number; lastInsertRowid: number | bigint; } /** * Prepared statement interface * Common interface used across all database modules */ export interface PreparedStatement { run: (...args: unknown[]) => RunResult; get: (...args: unknown[]) => unknown; all: (...args: unknown[]) => unknown[]; } /** * better-sqlite3 native statement type */ interface BetterSQLiteStatement { all: (...params: unknown[]) => unknown[]; get: (...params: unknown[]) => unknown; run: (...params: unknown[]) => { changes: number; lastInsertRowid: number | bigint; }; } /** * pg client type */ interface PgClient { query: (sql: string, params: unknown[]) => Promise<{ rows: unknown[]; rowCount: number | null; }>; } /** * Base statement interface * All statement wrappers must implement these methods */ export declare abstract class Statement { /** * Execute statement and return all rows * @param params - Query parameters * @returns All matching rows */ abstract all(...params: unknown[]): object[]; /** * Execute statement and return first row * @param params - Query parameters * @returns First matching row or undefined */ abstract get(...params: unknown[]): object | undefined; /** * Execute statement without returning rows * @param params - Query parameters * @returns Execution info (changes, lastInsertRowid) */ abstract run(...params: unknown[]): RunResult; /** * Release statement resources */ finalize(): void; } /** * SQLite statement wrapper (better-sqlite3) */ export declare class SQLiteStatement extends Statement { private stmt; constructor(stmt: BetterSQLiteStatement); all(...params: unknown[]): object[]; get(...params: unknown[]): object | undefined; run(...params: unknown[]): RunResult; finalize(): void; } export { NodeSQLiteStatement } from './node-sqlite-statement.js'; /** * PostgreSQL statement wrapper (pg) * * Maps pg's async query interface to synchronous-like API * Note: This requires careful handling in the adapter */ export declare class PostgreSQLStatement extends Statement { private client; private sql; constructor(client: PgClient, sql: string); /** * Convert SQLite ? placeholders to PostgreSQL $1, $2, ... * @param sql - SQL with ? placeholders * @returns SQL with $N placeholders * * Note: This naive implementation replaces all '?' characters. * It does not handle '?' inside SQL string literals or comments. * For production use with complex SQL, consider a proper SQL parser. */ static convertPlaceholders(sql: string): string; all(..._params: unknown[]): object[]; get(..._params: unknown[]): object | undefined; run(..._params: unknown[]): RunResult; allAsync(...params: unknown[]): Promise; getAsync(...params: unknown[]): Promise; /** * Execute statement asynchronously without returning rows * * Note: lastInsertRowid requires the SQL to include 'RETURNING id'. * PostgreSQL does not have SQLite's last_insert_rowid() equivalent. */ runAsync(...params: unknown[]): Promise; finalize(): void; } //# sourceMappingURL=statement.d.ts.map