UNPKG

@jakub.knejzlik/ts-query

Version:

TypeScript implementation of SQL builder

84 lines (83 loc) 3.33 kB
import { Condition } from "./Condition"; import { Expression } from "./Expression"; import { ISQLFlavor } from "./Flavor"; import { SelectQuery, Table } from "./Query"; import { ICompilable, IMetadata, IQueryTarget, ISequelizable, ISequelizableOptions, ISerializable, ISerializableOptions, MetadataOperationType, OperationType } from "./interfaces"; type RowRecord = Record<string, Expression>; type RowRecordInput = Record<string, Expression | any>; export declare class MutationBase { protected _table: Table; constructor(table: string, alias?: string); getTable(): Table; getTableNames(): string[]; clone(): this; static deserialize(json: string): DeleteMutation | InsertMutation | UpdateMutation; } export declare class DeleteMutation extends MutationBase implements ISerializable, ISequelizable, IMetadata, ICompilable { protected _where: Condition[]; getOperationType(): MetadataOperationType; getWhere(): Condition[]; clone(): this; where(condition: Condition): this; toSQL(flavor?: ISQLFlavor, options?: ISequelizableOptions, transformed?: boolean): string; /** * Compile this mutation using the provided target. */ compile<T>(target: IQueryTarget<T>): T; serialize(opts?: ISerializableOptions): string; toJSON(): { type: OperationType; table: any; where: any[]; }; static fromJSON({ table, where }: any): DeleteMutation; } export declare class InsertMutation extends MutationBase implements ISerializable, ISequelizable, IMetadata, ICompilable { protected _values?: RowRecord[]; protected _selectWithColumns: [SelectQuery, string[] | undefined]; getOperationType(): MetadataOperationType; getValues(): RowRecord[] | undefined; getSelectWithColumns(): [SelectQuery, string[] | undefined] | undefined; clone(): this; removeAllValues(): this; allValues(): RowRecord[]; values(values: RowRecordInput[]): this; select(query: SelectQuery, columns?: string[]): this; toSQL(flavor?: ISQLFlavor, options?: ISequelizableOptions, transformed?: boolean): string; /** * Compile this mutation using the provided target. */ compile<T>(target: IQueryTarget<T>): T; serialize(opts?: ISerializableOptions): string; toJSON(): { type: OperationType; table: any; values: RowRecord[]; select: any[]; }; static fromJSON({ table, values, select }: any): InsertMutation; } export declare class UpdateMutation extends MutationBase implements ISerializable, ISequelizable, IMetadata, ICompilable { protected _values: RowRecord; protected _where: Condition[]; getOperationType(): MetadataOperationType; getSetValues(): RowRecord; getWhere(): Condition[]; clone(): this; set(values: RowRecordInput): this; where(condition: Condition): this; toSQL(flavor?: ISQLFlavor, options?: ISequelizableOptions, transformed?: boolean): string; /** * Compile this mutation using the provided target. */ compile<T>(target: IQueryTarget<T>): T; serialize(opts?: ISerializableOptions): string; toJSON(): { type: OperationType; table: any; values: {}; where: any[]; }; static fromJSON({ table, values, where }: any): UpdateMutation; } export {};