inceptum
Version:
hipages take on the foundational library for enterprise-grade apps written in NodeJS
74 lines (73 loc) • 2.45 kB
TypeScript
import * as mysql from 'mysql';
import { Factory } from 'generic-pool';
import { DBTransaction } from '../db/DBTransaction';
import { ConnectionPool, ConnectionConfig } from '../db/ConnectionPool';
import { DBClient, DBClientConfig } from '../db/DBClient';
/**
* CONFIGURATION OBJECTS
*/
export interface MySQLConnectionConfig extends ConnectionConfig {
/**
* The hostname of the database you are connecting to. (Default: localhost)
*/
host: string;
/**
* The port number to connect to. (Default: 3306)
*/
port?: number;
/**
* Name of the database to connect to
*/
database: string;
/**
* User used to connect
*/
user: string;
/**
* Password used to authenticate on connection
*/
password: string;
/**
* The milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10 seconds)
*/
connectTimeout?: number;
/**
* The source IP address to use for TCP connection
*/
localAddress?: string;
/**
* The path to a unix domain socket to connect to. When used host and port are ignored
*/
socketPath?: string;
/**
* The timezone used to store local dates. (Default: 'local')
*/
timezone?: string;
/**
* object with ssl parameters or a string containing name of ssl profile
*/
ssl?: any;
/**
* The character set to use in the connection
*/
charset?: string;
}
export interface MySQLClientConfiguration extends DBClientConfig<MySQLConnectionConfig> {
enable57Mode?: boolean;
}
export declare class MySQLTransaction extends DBTransaction<mysql.IConnection> {
protected runQueryInConnection(sql: string, bindsArr: Array<any>): Promise<any>;
getTransactionBeginSQL(): string;
}
/**
* A MySQL client you can use to execute queries against MySQL
*/
export declare class MySQLClient extends DBClient<mysql.IConnection, MySQLTransaction, MySQLConnectionConfig, MySQLClientConfiguration> {
enable57Mode: boolean;
constructor(clientConfig: MySQLClientConfiguration);
initialise(): Promise<void>;
getConnectionFactory(name: string, connectionConfig: MySQLConnectionConfig): Factory<mysql.IConnection>;
getNewDBTransaction(readonly: boolean, connectionPool: ConnectionPool<mysql.IConnection>): MySQLTransaction;
getPingQuery(): string;
getDefaultConnectionConfig(): MySQLConnectionConfig;
}