rawsql-ts
Version:
[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
37 lines (36 loc) • 1.34 kB
TypeScript
import { SelectQuery, SimpleSelectQuery } from "../models/SelectQuery";
/**
* SqlParamInjector injects state parameters into a SelectQuery model,
* creating WHERE conditions and setting parameter values.
*/
export declare class SqlParamInjector {
private tableColumnResolver?;
private options;
constructor(optionsOrResolver?: {
ignoreCaseAndUnderscore?: boolean;
} | ((tableName: string) => string[]), options?: {
ignoreCaseAndUnderscore?: boolean;
});
/**
* Injects parameters as WHERE conditions into the given query model.
* @param query The SelectQuery to modify
* @param state A record of parameter names and values
* @returns The modified SelectQuery
*/
inject(query: SimpleSelectQuery | string, state: Record<string, number | string | boolean | Date | null | undefined | Condition>): SelectQuery;
}
type Condition = {
'='?: number | string | boolean | Date;
min?: number | string | Date;
max?: number | string | Date;
like?: string;
in?: (number | string | Date)[];
any?: (number | string | Date)[];
'<'?: number | string | Date;
'>'?: number | string | Date;
'!='?: number | string | boolean | Date;
'<>'?: number | string | boolean | Date;
'<='?: number | string | Date;
'>='?: number | string | Date;
};
export {};