swaf/dist/db/Query.d.ts

48 lines
1.4 KiB
TypeScript
Raw Normal View History

2020-04-22 15:52:17 +02:00
import { QueryResult } from "./MysqlConnectionManager";
import { Connection } from "mysql";
export default class Query {
static select(table: string, ...fields: string[]): Query;
static update(table: string, data: {
[key: string]: any;
}): Query;
static delete(table: string): Query;
private readonly type;
private readonly table;
private readonly fields;
private _where;
private _limit?;
private _offset?;
private _sortBy?;
private _sortDirection?;
private _foundRows;
private constructor();
where(field: string, value: string | Date | Query | any, operator?: WhereOperator, test?: WhereTest): Query;
whereNot(field: string, value: string | Date | Query | any, operator?: WhereOperator): Query;
orWhere(field: string, value: string | Date | Query | any): Query;
whereIn(field: string, value: any[]): Query;
limit(limit: number, offset?: number): Query;
first(): Query;
sortBy(field: string, direction?: 'ASC' | 'DESC'): Query;
withTotalRowCount(): Query;
toString(final?: boolean): string;
build(): string;
get variables(): any[];
isCacheable(): boolean;
execute(connection?: Connection): Promise<QueryResult>;
}
export declare enum QueryType {
SELECT = 0,
UPDATE = 1,
DELETE = 2
}
declare enum WhereOperator {
AND = "AND",
OR = "OR"
}
declare enum WhereTest {
EQUALS = "=",
DIFFERENT = "!=",
IN = " IN "
}
export {};