@jakub.knejzlik/ts-query
Version:
TypeScript implementation of SQL builder
66 lines (65 loc) • 2.58 kB
TypeScript
import { Condition } from "./Condition";
import { Expression } from "./Expression";
import { ISQLFlavor } from "./Flavor";
import { SelectQuery, Table } from "./Query";
import { IMetadata, ISequelizable, ISequelizableOptions, ISerializable, 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);
getTableNames(): string[];
clone(): this;
static deserialize(json: string): DeleteMutation | InsertMutation | UpdateMutation;
}
export declare class DeleteMutation extends MutationBase implements ISerializable, ISequelizable, IMetadata {
protected _where: Condition[];
getOperationType(): MetadataOperationType;
clone(): this;
where(condition: Condition): this;
toSQL(flavor?: ISQLFlavor, options?: ISequelizableOptions, transformed?: boolean): string;
serialize(): string;
toJSON(): {
type: OperationType;
table: any;
where: any[];
};
static fromJSON({ table, where }: any): DeleteMutation;
}
export declare class InsertMutation extends MutationBase implements ISerializable, ISequelizable, IMetadata {
protected _values?: RowRecord[];
protected _selectWithColumns: [SelectQuery, string[] | undefined];
getOperationType(): MetadataOperationType;
clone(): this;
removeAllValues(): this;
allValues(): RowRecord[];
values(values: RowRecordInput[]): this;
select(query: SelectQuery, columns?: string[]): this;
toSQL(flavor?: ISQLFlavor, options?: ISequelizableOptions, transformed?: boolean): string;
serialize(): 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 {
protected _values: RowRecord;
protected _where: Condition[];
getOperationType(): MetadataOperationType;
clone(): this;
set(values: RowRecordInput): this;
where(condition: Condition): this;
toSQL(flavor?: ISQLFlavor, options?: ISequelizableOptions, transformed?: boolean): string;
serialize(): string;
toJSON(): {
type: OperationType;
table: any;
values: {};
where: any[];
};
static fromJSON({ table, values, where }: any): UpdateMutation;
}
export {};