@jakub.knejzlik/ts-query
Version:
TypeScript implementation of SQL builder
51 lines (50 loc) • 2.49 kB
TypeScript
import { Condition } from "./Condition";
import { ISQLFlavor } from "./Flavor";
import { ISequelizable, ISequelizableOptions, ISerializable } from "./interfaces";
export type ExpressionRawValue = string | number | bigint | boolean;
export type ExpressionValue = ExpressionBase | ExpressionRawValue | FunctionExpression | OperationExpression | Condition | Date;
export declare class ExpressionBase implements ISerializable, ISequelizable {
static deserialize(value: ExpressionValue): ExpressionBase;
static deserializeValue(value: ExpressionValue): ValueExpression;
static deserializeRaw(value: ExpressionRawValue): RawExpression;
toSQL(_: ISQLFlavor, __?: ISequelizableOptions): string;
serialize(): string;
}
export declare class Expression<T = ExpressionValue> extends ExpressionBase {
value: T;
constructor(value: T);
toSQL(flavor: ISQLFlavor, options?: ISequelizableOptions): string;
serialize(): string;
static escapeColumn(column: ExpressionRawValue): string;
static escapeString(column: ExpressionRawValue): string;
static escapeExpressionValue(column: ExpressionValue): string;
}
export declare class ValueExpression extends Expression<ExpressionValue> {
static isValueString(str: string): boolean;
static isValueDateString(str: string): boolean;
toSQL(flavor: ISQLFlavor, options?: ISequelizableOptions): string;
serialize(): string;
static deserialize(value: ExpressionValue): ValueExpression;
}
export declare class RawExpression extends Expression<ExpressionRawValue> {
static isValueString(str: string): boolean;
toSQL(flavor: ISQLFlavor, _?: ISequelizableOptions): string;
serialize(): string;
static deserialize(value: ExpressionRawValue): RawExpression;
}
export declare class FunctionExpression extends Expression<ExpressionValue[]> {
name: string;
constructor(name: string, ...args: ExpressionValue[]);
toSQL(flavor: ISQLFlavor, _?: ISequelizableOptions): string;
static isValidString(str: string): boolean;
static deserialize(value: ExpressionValue): FunctionExpression;
serialize(): string;
}
export declare class OperationExpression extends Expression<ExpressionValue[]> {
operation: any;
constructor(operation: any, ...args: ExpressionValue[]);
toSQL(flavor: ISQLFlavor, _?: ISequelizableOptions): string;
static isValidString(str: string): boolean;
static deserialize(value: ExpressionValue): OperationExpression;
serialize(): string;
}