index.d.ts
2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import * as mysql from 'mysql';
import * as Bluebird from 'bluebird';
export function createConnection(connectionUri: string | mysql.ConnectionConfig): Bluebird<Connection>;
export function createPool(config: mysql.PoolConfig | string): Pool;
export { Types, escape, escapeId, format, ConnectionOptions, ConnectionConfig, PoolConfig } from 'mysql';
export interface QueryFunction {
(query: mysql.Query | string | mysql.QueryOptions): Bluebird<any>;
(options: string, values: any): Bluebird<any>;
}
export interface Connection {
query: QueryFunction;
beginTransaction(options?: mysql.QueryOptions): Bluebird<void>;
commit(options?: mysql.QueryOptions): Bluebird<void>;
rollback(options?: mysql.QueryOptions): Bluebird<void>;
changeUser(options?: mysql.ConnectionOptions): Bluebird<void>;
ping(options?: mysql.QueryOptions): Bluebird<void>;
queryStream(sql: string, values: any): mysql.Query;
statistics(options?: mysql.QueryOptions): Bluebird<void>;
end(options?: mysql.QueryOptions): Bluebird<void>;
destroy(): void;
pause(): void;
resume(): void;
escape(value: any, stringifyObjects?: boolean, timeZone?: string): string;
escapeId(value: string, forbidQualified?: boolean): string;
format(sql: string, values: any[], stringifyObjects?: boolean, timeZone?: string): string;
}
export interface PoolConnection extends Connection {
release(): any;
destroy(): any;
}
export interface Pool {
getConnection(): Bluebird<PoolConnection>;
releaseConnection(connection: PoolConnection): void;
query: QueryFunction;
end(options?: mysql.QueryOptions): Bluebird<void>;
release(options?: mysql.QueryOptions): Bluebird<void>;
escape(value: any, stringifyObjects?: boolean, timeZone?: string): string;
escapeId(value: string, forbidQualified?: boolean): string;
on(ev: 'connection' | 'acquire' | 'release', callback: (connection: mysql.PoolConnection) => void): mysql.Pool;
on(ev: 'error', callback: (err: mysql.MysqlError) => void): mysql.Pool;
on(ev: 'enqueue', callback: (err?: mysql.MysqlError) => void): mysql.Pool;
on(ev: string, callback: (...args: any[]) => void): mysql.Pool;
}