UNPKG

@pgxsinkit/pgwasm

Version:
42 lines • 1.67 kB
declare const TemplateType: { readonly part: "part"; readonly container: "container"; }; /** A literal piece of SQL (an identifier or raw text) spliced into a template without a parameter. */ export interface TemplatePart { readonly _templateType: typeof TemplateType.part; readonly str: string; } /** A nested template: its strings and its parameter values. */ export interface TemplateContainer { readonly _templateType: typeof TemplateType.container; readonly strings: TemplateStringsArray; readonly values: unknown[]; } /** A parametrized query: `$1`-numbered text and its parameters. */ export interface TemplatedQuery { readonly query: string; readonly params: unknown[]; } /** * Nest SQL templates without losing their parametrization: * * ```ts * pg.sql`SELECT * FROM tale ${withFilter ? sql`WHERE foo = ${fooVar}` : sql``}` * ``` */ export declare function sql(strings: TemplateStringsArray, ...values: unknown[]): TemplateContainer; /** * An identifier spliced into a template, double-quoted and not parametrized: * * ```ts * pg.sql`SELECT * FROM ${identifier`foo`} WHERE ${identifier`id`} = ${id}` * ``` */ export declare function identifier(strings: TemplateStringsArray, ...values: unknown[]): TemplatePart; /** Raw SQL spliced into a template as it is, neither parametrized nor escaped. */ export declare function raw(strings: TemplateStringsArray, ...values: unknown[]): TemplatePart; /** Turn a template into `$1`-numbered query text and its parameters. */ export declare function query(strings: TemplateStringsArray, ...values: unknown[]): TemplatedQuery; export {}; //# sourceMappingURL=templating.d.ts.map