UNPKG

refql

Version:

A Node.js and Deno library for composing and running SQL queries.

55 lines (54 loc) 3.32 kB
import Operation from "../RQLTag/Operation"; import RQLNode from "../RQLTag/RQLNode"; import { SQLTag } from "../SQLTag"; import Raw from "../SQLTag/Raw"; import { LogicOperator, OrdOperator, Simplify, TagFunctionVariable } from "../common/types"; import PropType from "./PropType"; import SQLProp from "./SQLProp"; interface Prop<TableId extends string = any, As extends string = any, Output = any, Params = any, IsOmitted extends boolean = any, HasDefault extends boolean = any, HasOp extends boolean = any> extends RQLNode, PropType<As> { tableId: TableId; params: Params; col?: string; output: Output; isOmitted: IsOmitted; hasDefaultValue: HasDefault; arrayOf(): Prop<TableId, As, Output[], Params, IsOmitted, HasDefault, HasOp>; nullable(): Prop<TableId, As, Output | null, Params, IsOmitted, HasDefault, HasOp>; eq<Params2 = {}>(run: TagFunctionVariable<Simplify<Params & Params2>, Output> | Output): Prop<TableId, As, Output, Simplify<Params & Params2>, IsOmitted, HasDefault, true>; notEq: this["eq"]; isNull<Params2 = {}>(): Prop<TableId, As, Output, Simplify<Params & Params2>, IsOmitted, HasDefault, true>; notIsNull: this["isNull"]; like<Params2 = {}>(run: TagFunctionVariable<Simplify<Params & Params2>, string> | string): Prop<TableId, As, Output, Simplify<Params & Params2>, IsOmitted, HasDefault, true>; notLike: this["like"]; iLike: this["like"]; notILike: this["like"]; in<Params2 = {}>(run: TagFunctionVariable<Simplify<Params & Params2>, Output[]> | Output[]): Prop<TableId, As, Output, Simplify<Params & Params2>, IsOmitted, HasDefault, true>; notIn: this["in"]; gt<Params2 = {}>(run: TagFunctionVariable<Simplify<Params & Params2>, Output> | Output): Prop<TableId, As, Output, Simplify<Params & Params2>, IsOmitted, HasDefault, true>; gte: this["gt"]; lt: this["gt"]; lte: this["gt"]; asc(): Prop<TableId, As, Output, Params, IsOmitted, HasDefault, true>; desc: this["asc"]; or<Params2 = {}>(prop: Prop<TableId> | SQLProp<any, any, Params2> | SQLTag<Params2>): Prop<TableId, As, Output, Simplify<Params & Params2>, IsOmitted, HasDefault, true>; and: this["or"]; operations: Operation<Params>[]; hasOp: HasOp; omit(): Prop<TableId, As, Output, Params, true, HasDefault, HasOp>; hasDefault(): Prop<TableId, As, Output, Params, IsOmitted, true, HasOp>; interpret: () => Raw; } declare function Prop<TableId extends string, As extends string>(as: As, col?: string): Prop<TableId, As, any, {}, false, false, false>; declare namespace Prop { var isProp: (x: any) => x is Prop; } export declare function nullable(this: Prop): any; export declare function eq(notEq?: boolean): (this: Prop, run: any) => any; export declare function isNull(notIsNull?: boolean): (this: Prop) => any; export declare function like(caseSensitive?: boolean, notLike?: boolean): (this: Prop, run: any) => any; export declare function whereIn(notIn?: boolean): (this: Prop, run: any) => any; export declare function ord(operator: OrdOperator): (this: Prop, run: any) => any; export declare function dir(descending?: boolean): (this: Prop) => any; export declare function omit(this: Prop): any; export declare function logic(operator: LogicOperator): (this: Prop, run: any) => any; export default Prop;