refql
Version:
A Node.js and Deno library for composing and running SQL queries.
34 lines (33 loc) • 1.7 kB
TypeScript
import { flConcat } from "../common/consts";
import { Querier, RefQLRows, RequiredRefQLOptions, RQLOutput, RQLParams, Selectable } from "../common/types";
import { SQLTag } from "../SQLTag";
import { Table } from "../Table";
import RQLNode from "./RQLNode";
export interface Next {
tag: RQLTag<any, any, any, RefQLRows>;
link: [string, string[]];
single: boolean;
}
interface InterpretedRQLTag<Params = any, Output = any> {
tag: SQLTag<Params, Output>;
next: Next[];
}
export interface RQLTag<TableId extends string = any, Props = any, Components extends Selectable<TableId, Props>[] = Selectable<TableId, Props>[], Params = any, Output = any> extends RQLNode {
(params: {} extends Params ? Params | void : Params): Promise<Output[]>;
tableId: TableId;
props: Props;
params: Params;
output: Output;
table: Table<TableId>;
nodes: RQLNode[];
options: RequiredRefQLOptions;
interpreted: InterpretedRQLTag<Params, Output>;
concat<Components2 extends Selectable<TableId, Props>[]>(other: RQLTag<TableId, Props, Components2>): RQLTag<TableId, Props, [...Components, ...Components2], RQLParams<TableId, Props, [...Components, ...Components2]>, RQLOutput<TableId, Props, [...Components, ...Components2]>>;
[flConcat]: this["concat"];
interpret(where?: SQLTag): InterpretedRQLTag<Params, Output>;
compile(params: Params): [string, any[], Next[]];
run(params: Params, querier?: Querier): Promise<Output[]>;
}
export declare function createRQLTag(table: Table, nodes: RQLNode[], options: RequiredRefQLOptions): RQLTag<any, any, Selectable<any, any>[], any, any>;
export declare const isRQLTag: (x: any) => x is RQLTag;
export {};