UNPKG

tspace-mysql

Version:

Tspace MySQL is a promise-based ORM for Node.js, designed with modern TypeScript and providing type safety for schema databases.

165 lines (164 loc) 5.69 kB
import { EventEmitter } from "events"; import { StateManager } from "../StateManager"; import { Blueprint } from "../Blueprint"; import type { TConstant, TPoolConnected } from "../../types"; export declare abstract class BaseDriver extends EventEmitter { private SLOW_QUERY_EXECUTE_TIME; private SLOW_QUERY_LIMIT_LENGTH; protected pool: any; protected poolTrx: any; protected options: Record<string, any>; protected MESSAGE_TRX_NOT_STARTED: string; protected MESSAGE_TRX_CLOSED: string; protected abstract connect(): TPoolConnected; protected abstract disconnect(pool: any): void; protected abstract meta(results: any, sql: string): void; protected abstract returning(results: any): any; protected import(mod: string): any; protected _detectEventQuery({ start, sql }: { start: number; sql: string; }): void; protected _messageSlowQuery(duration: number, sql: string): string; protected _detectQueryType(query: string): "SELECT" | "UPDATE" | "DELETE" | "INSERT" | "UNKNOWN"; protected _onPoolConnect(pool: any): void; protected _messageConnected(message: string): string; protected _messageError(message: string): string; } export declare abstract class QueryBuilder { protected $constants: (name: keyof TConstant) => any; protected $state: StateManager; constructor(state: StateManager); abstract select(): string; abstract insert(): string; abstract update(): string; abstract remove(): string; abstract any(): string; abstract getColumns({ database, table, }: { database: string; table: string; }): string; abstract getSchema({ database, table, }: { database: string; table: string; }): string; abstract getTables(database: string): string; abstract hasTable({ database, table, }: { database: string; table: string; }): string; abstract createDatabase(database: string): string; abstract createTable({ database, table, schema, }: { database: string; table: string; schema: Record<string, Blueprint> | string[]; }): string; abstract addColumn({ table, column, type, attributes, after, }: { table: string; column: string; type: string; attributes: string[]; after: string; }): string; abstract changeColumn({ table, column, type, attributes, }: { table: string; column: string; type: string; attributes: string[]; }): string; abstract getChildFKs({ database, table, }: { database: string; table: string; }): string; abstract getFKs({ database, table, }: { database: string; table: string; }): string; abstract hasFK({ database, table, constraint, }: { database: string; table: string; constraint: string; }): string; abstract dropFK({ table, constraint, }: { table: string; constraint: string; }): string; abstract addFK({ table, tableRef, key, constraint, foreign, }: { table: string; tableRef: string; key: string; constraint: string; foreign: { references: string; onDelete: string; onUpdate: string; }; }): string; abstract getIndexes({ database, table, }: { database: string; table: string; }): string; abstract hasIndex({ database, table, name, }: { database: string; table: string; name: string; }): string; abstract addIndex({ table, name, columns, }: { table: string; name: string; columns: string[]; }): string; abstract dropIndex({ table, name }: { table: string; name: string; }): string; abstract hasUnique({ database, table, name, }: { database: string; table: string; name: string; }): string; abstract addUnique({ table, name, columns, }: { table: string; name: string; columns: string[]; }): string; abstract dropUnique({ table, name }: { table: string; name: string; }): string; abstract hasPrimaryKey({ database, table, }: { database: string; table: string; }): string; abstract addPrimaryKey({ table, columns, }: { table: string; columns: string[]; }): string; abstract dropPrimaryKey({ table }: { table: string; }): string; abstract getDatabase(database: string): string; abstract dropDatabase(database: string): string; abstract dropView(view: string): string; abstract dropTable(table: string): string; abstract truncate(table: string): string; abstract sleep(second: number): string; abstract format(sql: (string | null)[] | string): string; abstract getActiveConnections(): string; abstract getMaxConnections(): string; protected abstract bindJoin(values: string[]): string | null; protected abstract bindWhere(values: string[]): string | null; protected abstract bindOrderBy(values: string[]): string | null; protected abstract bindGroupBy(values: string[]): string | null; protected abstract bindSelect(values: string[], opts?: { distinct?: string; }): string; protected abstract bindFrom(args: { from: string[]; alias: string | null; rawAlias: string | null; }): string; protected abstract bindLimit(limit: string | number | null): string; protected abstract bindOffset(offset: string | number | null): string; protected abstract bindHaving(having: string): string; }