import { QueryComposer } from '../core/query-composer'; import { type RawFilter } from '../core/raw-filter'; /** * Create EXISTS condition for use in where() * * Returns a filter object that when passed to where() generates an EXISTS clause. * Optimizes the subquery by replacing SELECT columns with SELECT 1. * Uses parameterized queries to prevent SQL injection. * * @param subquery - QueryComposer subquery * @returns Filter object with parameterized EXISTS condition * * @example * ```typescript * const qc = new QueryComposer(PostSchema, 'posts') * .where(exists( * subquery(CommentSchema, 'comments') * .whereRaw('comments.post_id = posts.id') * .where({ approved: true }) * )); * // Generates: WHERE EXISTS (SELECT 1 FROM comments WHERE ... AND approved = $N) * ``` */ export declare function exists(subquery: QueryComposer): RawFilter; /** * Create NOT EXISTS condition for use in where() * * Returns a filter object that when passed to where() generates a NOT EXISTS clause. * Uses parameterized queries to prevent SQL injection. * * @param subquery - QueryComposer subquery * @returns Filter object with parameterized NOT EXISTS condition * * @example * ```typescript * const qc = new QueryComposer(PostSchema, 'posts') * .where(notExists( * subquery(CommentSchema, 'comments') * .whereRaw('comments.post_id = posts.id') * )); * // Generates: WHERE NOT EXISTS (SELECT 1 FROM comments WHERE ...) * ``` */ export declare function notExists(subquery: QueryComposer): RawFilter; /** * Create a correlated reference for use in subqueries * * @param table - Table name or alias * @param column - Column name * @returns Reference string * * @example * ```typescript * subquery(CommentSchema, 'comments') * .whereRaw(`comments.post_id = ${ref('posts', 'id')}`); * ``` */ export declare function ref(table: string, column: string): string; /** * Create a raw SQL expression * * WARNING: This passes the expression through unchanged. Do NOT use with * user-controlled input. Only use for developer-authored SQL expressions. * * @param expression - Raw SQL expression * @returns The expression unchanged */ export declare function raw(expression: string): string; /** * Create a lateral subquery for correlated expressions. * Uses parameterized queries to prevent SQL injection. * * @param subquery - QueryComposer subquery * @param alias - Alias for the subquery * @returns Lateral subquery configuration with parameterized SQL */ export declare function lateral(subquery: QueryComposer, alias: string): { sql: string; values: unknown[]; alias: string; type: 'lateral'; }; //# sourceMappingURL=exists.d.ts.map