/** * PostgreSQL JSONB operators and functions * * Provides type-safe helpers for working with JSONB columns. * All filter functions return parameterized queries to prevent SQL injection. */ import { type RawFilter } from '../core/raw-filter'; /** * JSONB contains operator (@>) * * Tests if the JSONB column contains the given value. * * @param column - JSONB column name * @param value - Value to check for containment * @returns Filter object for use with where() * * @example * ```typescript * qc.where(jsonbContains('data', { status: 'active' })); * // Generates: data @> $1::jsonb (parameterized) * ``` */ export declare function jsonbContains(column: string, value: unknown): RawFilter; /** * JSONB is contained by operator (<@) * * Tests if the JSONB column is contained by the given value. * * @param column - JSONB column name * @param value - Value to check containment against * @returns Filter object for use with where() */ export declare function jsonbContainedBy(column: string, value: unknown): RawFilter; /** * JSONB has key operator (?) * * Tests if the JSONB column has a specific key. * * @param column - JSONB column name * @param key - Key to check for * @returns Filter object for use with where() * * @example * ```typescript * qc.where(jsonbHasKey('data', 'status')); * // Generates: data ? $1 (parameterized) * ``` */ export declare function jsonbHasKey(column: string, key: string): RawFilter; /** * JSONB has all keys operator (?&) * * Tests if the JSONB column has all specified keys. * * @param column - JSONB column name * @param keys - Keys to check for * @returns Filter object for use with where() * * @example * ```typescript * qc.where(jsonbHasAllKeys('data', ['status', 'type'])); * // Generates: data ?& array[$1, $2] (parameterized) * ``` */ export declare function jsonbHasAllKeys(column: string, keys: string[]): RawFilter; /** * JSONB has any key operator (?|) * * Tests if the JSONB column has any of the specified keys. * * @param column - JSONB column name * @param keys - Keys to check for * @returns Filter object for use with where() * * @example * ```typescript * qc.where(jsonbHasAnyKey('data', ['status', 'state'])); * // Generates: data ?| array[$1, $2] (parameterized) * ``` */ export declare function jsonbHasAnyKey(column: string, keys: string[]): RawFilter; /** * JSONB path extraction (->) * * Extracts a JSON object at the specified path (returns JSONB). * * @param column - JSONB column name * @param path - Array of path elements * @returns SQL expression string * * @example * ```typescript * const expr = jsonbPath('data', ['user', 'profile']); * // Returns: data->'user'->'profile' * ``` */ export declare function jsonbPath(column: string, path: string[]): string; /** * JSONB path text extraction (->>) * * Extracts a JSON value at the specified path (returns text). * Uses ->> for the last element to get text output. * * @param column - JSONB column name * @param path - Array of path elements * @returns SQL expression string * * @example * ```typescript * const expr = jsonbPathText('data', ['user', 'name']); * // Returns: data->'user'->>'name' * ``` */ export declare function jsonbPathText(column: string, path: string[]): string; /** * JSONB extract path function * * Uses jsonb_extract_path for path extraction. * * @param column - JSONB column name * @param path - Array of path elements * @returns SQL expression string * * @example * ```typescript * const expr = jsonbExtract('data', ['settings', 'theme']); * // Returns: jsonb_extract_path(data, 'settings', 'theme') * ``` */ export declare function jsonbExtract(column: string, path: string[]): string; /** * JSONB extract path text function * * Uses jsonb_extract_path_text for text extraction. * * @param column - JSONB column name * @param path - Array of path elements * @returns SQL expression string */ export declare function jsonbExtractText(column: string, path: string[]): string; /** * JSONB set function * * Creates a jsonb_set expression for updating nested values. * * @param column - JSONB column name * @param path - Array of path elements * @param value - New value to set * @param createMissing - Whether to create missing path elements * @returns SQL expression string */ export declare function jsonbSet(column: string, path: string[], value: unknown, createMissing?: boolean): string; /** * JSONB array elements * * Creates a jsonb_array_elements expression. * * @param column - JSONB column or expression * @returns SQL expression string */ export declare function jsonbArrayElements(column: string): string; /** * JSONB object keys * * Creates a jsonb_object_keys expression. * * @param column - JSONB column or expression * @returns SQL expression string */ export declare function jsonbObjectKeys(column: string): string; //# sourceMappingURL=jsonb.d.ts.map