db-sql-toolkit
Version:
Helps with SQL statements, database migration, and bulk execution.
24 lines (23 loc) • 1.71 kB
TypeScript
import type { BulkExecuteStatementParams, BulkStatementParams } from "./bulk";
type DefaultParamType = string | number | boolean | null;
type StatementParams<TParam = DefaultParamType> = [string, TParam[]];
type FunctionParameter<TData, TParam> = (data: TData) => TParam[];
type SqlReturnType<TData, TParam> = StatementParams<TParam> | BulkStatementParams<TData, TParam> | BulkExecuteStatementParams<TParam>;
type StatementSqlFnParams<TParam> = (TParam | SqlLiteral | StatementParams<TParam>)[];
type BulkStatementSqlFnParams<TData, TParam> = [
...(TParam | SqlLiteral | StatementParams<TParam>)[],
FunctionParameter<TData, TParam>
];
type BulkExecuteStatementSqlFnParams<TParam> = (TParam | TParam[] | SqlLiteral | StatementParams<TParam>)[];
type AllowedSqlParams<TData, TParam> = [
...(TParam | TParam[] | SqlLiteral | StatementParams<TParam> | FunctionParameter<TData, TParam>)[]
];
declare function sql<TParam = DefaultParamType>(strings: TemplateStringsArray, ...values: StatementSqlFnParams<NoInfer<TParam>>): StatementParams<TParam>;
declare function sql<TData, TParam = DefaultParamType>(strings: TemplateStringsArray, ...values: BulkStatementSqlFnParams<TData, NoInfer<TParam>>): BulkStatementParams<TData, TParam>;
declare function sql<TParam = DefaultParamType>(strings: TemplateStringsArray, ...values: BulkExecuteStatementSqlFnParams<NoInfer<TParam>>): BulkExecuteStatementParams<TParam>;
interface SqlLiteral {
value: string;
}
declare function sqlLiteral(value: string): SqlLiteral;
export type { DefaultParamType, StatementParams, StatementSqlFnParams, BulkExecuteStatementSqlFnParams, BulkStatementSqlFnParams, SqlReturnType, AllowedSqlParams, };
export { sql, sqlLiteral };