Files
bun-sqlite/dist/utils/sql-generator.d.ts
T

40 lines
1.1 KiB
TypeScript

import type { ServerQueryParam, SQLInsertGenValueType } from "../types";
type Param<T extends {
[key: string]: any;
} = {
[key: string]: any;
}> = {
genObject?: ServerQueryParam<T>;
tableName: string;
dbFullName?: string;
count?: boolean;
/**
* Restrict to a single row id. Always combined with AND, regardless of
* `searchOperator`.
*/
targetId?: number | string;
};
type Return = {
string: string;
values: SQLInsertGenValueType[];
/**
* Just the `WHERE ...` clause (empty if there are no conditions) and its
* bound values. Used by UPDATE and DELETE.
*/
where: {
string: string;
values: SQLInsertGenValueType[];
};
};
/**
* # SQL Query Generator
* @description Generates a parameterized SQLite SELECT query. All values are
* returned in `values` to be bound; identifiers are validated.
*/
export default function sqlGenerator<T extends {
[key: string]: any;
} = {
[key: string]: any;
}>({ tableName: passedTableName, genObject, count, targetId, }: Param<T>): Return;
export {};