sqlite-prepare
Version:
A type-safe SQL query builder for Cloudflare D1
22 lines (21 loc) • 925 B
TypeScript
import { FragmentSQL } from './types';
/**
* Creates a SQL fragment that will be inserted directly into the query without being wrapped in parentheses
* Unlike raw(), this maintains parameter safety and query building capabilities
*
* @param strings - SQL query string with placeholders or template strings array
* @param values - Values to interpolate into the query
* @returns A FragmentSQL object with the query string and parameters
*
* @example
* // Using a template literal
* const columns = fragment`id, name, created_at`;
* const query = build`SELECT ${columns} FROM users`;
*
* @example
* // Using with parameters
* const condition = fragment`status = ${'active'} AND type = ${'user'}`;
* const query = build`SELECT * FROM users WHERE ${condition}`;
*/
export declare function fragment(strings: string | TemplateStringsArray, ...values: any[]): FragmentSQL;
export declare const f: typeof fragment;