@iamthes/query-builder
Version:
Builds sql query for RDBMS
65 lines (64 loc) • 2.19 kB
TypeScript
export default class Sql {
private _queryKind;
private _selects;
private _tables;
private _wheres;
private _whereConcat;
private _whereConcatDefault;
private _sets;
private _limit;
private _offset;
private _orderBys;
private _joins;
private _groupBys;
private _whereGroupCount;
private _openWhereGroupCount;
private _havings;
constructor();
private reset();
select(): any;
select(field: string): any;
select(func: string, field: any, alias: string): any;
between(field: any, value: any, otherValue: any): this;
table(table: Array<string>): any;
table(table: string): any;
from(table: Array<string>): any;
from(table: string): any;
into(table: string): any;
into(table: Array<string>): any;
private static _operators;
private _conditionExpr(field, value?, operator?);
where(field: any, operator?: any, value?: any): this;
whereNotIn(field: any, values: any): this;
whereIn(field: any, values: Array<string>, op?: string): this;
limit(limit: number, offset?: number): this;
top(n: number): this;
offset(offset: number): this;
skip(n: number): this;
notLike(field: any, match: any, side: any): this;
like(field: string, match?: string, side?: string, op?: string): this;
groupBy(fields: Array<string>): this;
andOp(): this;
orOp(): this;
beginWhereGroup(): this;
endWhereGroup(): this;
private _endQuery();
private static _joinTypes;
join(table: string, on: string, join: string): this;
leftJoin(table: string, on: string): this;
having(field: any, value: any): this;
orderBy(field: any, direction?: string): this;
get(): string;
getSelect(): string;
delete(table?: string): this;
getDelete(): string;
update(table?: string): this;
getUpdate(): string;
insert(): this;
set(name: any, value: any, wrapValue?: boolean): this;
getInsert(): string;
getLimit(sql: any, limit: any, offset: any): string;
private _where(sql);
private _wrap(value);
private _quote(value, wrapInQuotes);
}