@pardnchiu/mysql-pool
Version:
A MySQL connection pool solution designed specifically for Node.js, featuring intuitive chaining syntax that integrates query builder capabilities with read-write separation.
53 lines • 2.37 kB
TypeScript
import { ResultSetHeader } from "mysql2/promise";
interface MySQLConfig {
host?: string;
port?: number;
user?: string;
password?: string;
database?: string;
charset?: string;
connectionLimit?: number;
}
declare class MySQLPool {
private static config;
private static readPool;
private static writePool;
private static tableName;
private static selectAry;
private static joinAry;
private static whereAry;
private static bindingAry;
private static orderAry;
private static setAry;
private static queryLimit;
private static queryOffset;
private static withTotal;
private static currentTarget;
private static supportFunction;
private constructor();
private static correctConfig;
static init(config?: Record<string, MySQLConfig>): Promise<void>;
static close(): Promise<void>;
private static reset;
static table(tableName: string, target?: "read" | "write"): typeof MySQLPool;
static total(): typeof MySQLPool;
static select(...fields: string[]): typeof MySQLPool;
static innerJoin(table: string, first: string, operator: string, second?: string): typeof MySQLPool;
static leftJoin(table: string, first: string, operator: string, second?: string): typeof MySQLPool;
static rightJoin(table: string, first: string, operator: string, second?: string): typeof MySQLPool;
private static join;
static where(column: string, operator: any, value?: any): typeof MySQLPool;
static orderBy(column: string, direction?: "ASC" | "DESC" | "asc" | "desc"): typeof MySQLPool;
static limit(num: number): typeof MySQLPool;
static offset(num: number): typeof MySQLPool;
static increase(target: string, number?: number): typeof MySQLPool;
static get<T = any>(): Promise<T[]>;
static insert(data: Record<string, any>): Promise<number | null>;
static update(data?: Record<string, any>): Promise<ResultSetHeader>;
static upsert(data: Record<string, any>, updateData?: Record<string, any> | string): Promise<number | null>;
static query<T = any>(query: string, params?: any[], target?: "read" | "write"): Promise<T>;
static read<T = any>(query: string, params?: any[]): Promise<T>;
static write<T = any>(query: string, params?: any[]): Promise<T>;
}
export default MySQLPool;
//# sourceMappingURL=MySQLPool.d.ts.map