/** * escape sql param */ export declare function escape(param: any): string; export interface Result extends Dict { rows?: Dict[]; fields?: Dict<{ name: string; type: number; }>; affectedRows?: number; insertId?: number; } /** * @class DatabaseTools */ export interface Database { /** * database statistics */ statistics(): Promise; /** * exec query database */ exec(sql: string): Promise; /** * close database connection */ close(): void; /** * srart transaction */ transaction(): Promise; /** * commit transaction */ commit(): Promise; /** * rollback transaction and clear sql command queue */ rollback(): Promise; } export type Where = Dict | string; export interface SelectOptions { group?: string; order?: string; limit?: number | number[]; out?: string; count?: boolean; } export interface DatabaseCRUD { exec(sql: string): Promise; insert(table: string, row: Dict): Promise; insertSql(table: string, row: Dict): string; delete(table: string, where?: Where): Promise; deleteSql(table: string, where?: Where): string; update(table: string, row: Dict, where?: Where): Promise; updateSql(table: string, row: Dict, where?: Where): string; select(table: string, where?: Where, opts?: SelectOptions): Promise; selectSql(table: string, where?: Where, opts?: SelectOptions): string; selectCount(table: string, where?: Where, opts?: SelectOptions): Promise; selectOne(table: string, where?: Where, opts?: SelectOptions): Promise; query(sql: string): Promise; has(name: string): boolean; } export interface DatabaseTools extends DatabaseCRUD { has(table: string): boolean; load(SQL: string, SQL_ALTER: string[], SQL_INDEXES: string[], id?: string): Promise; scope(cb: (db: DatabaseCRUD, self: DatabaseTools) => Promise): Promise; transaction(cb: (db: DatabaseCRUD, self: DatabaseTools) => Promise): Promise; db(): Database; }