nano-queries
Version:
Simple and powerful database-agnostic query builder (SQL & NoSQL)
29 lines (28 loc) • 829 B
TypeScript
import { Query } from '../core/Query';
import { QueryBindings } from '../types';
export interface CommandWithBindings<T> {
command: string;
bindings: T[];
}
export interface Compiler<T> {
compile: (query: Query) => T;
}
export type SQLCompilerConfig = {
getPlaceholder: (valueIndex: number) => string;
onPostProcess?: (code: string) => string;
};
export declare class SQLCompiler implements Compiler<CommandWithBindings<QueryBindings>> {
private readonly config;
constructor(options?: Partial<SQLCompilerConfig>);
/**
* Compile query to SQL string and bindings
*/
compile(query: Query): CommandWithBindings<QueryBindings>;
/**
* Compile query to SQL string and bindings
*/
toSQL: (query: Query) => {
sql: string;
bindings: QueryBindings[];
};
}