Skip to content

Commit 217efd4

Browse files
trevorrunional
authored andcommitted
Add .promise() function on pools and connections (#31)
See https://github.com/sidorares/node-mysql2#using-promise-wrapper
1 parent a90d3e3 commit 217efd4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

index.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import './promise';
2+
import { Connection as PromiseConnection, Pool as PromisePool, PoolConnection as PromisePoolConnection } from './promise';
33
import * as mysql from 'mysql';
44
export * from 'mysql';
55

@@ -9,9 +9,12 @@ export interface Connection extends mysql.Connection {
99
execute<T extends mysql.RowDataPacket[][] | mysql.RowDataPacket[] | mysql.OkPacket | mysql.OkPacket[]>(options: mysql.QueryOptions, callback?: (err: mysql.QueryError | null, result: T, fields?: mysql.FieldPacket[]) => any): mysql.Query;
1010
execute<T extends mysql.RowDataPacket[][] | mysql.RowDataPacket[] | mysql.OkPacket | mysql.OkPacket[]>(options: mysql.QueryOptions, values: any | any[] | { [param: string]: any }, callback?: (err: mysql.QueryError | null, result: T, fields: mysql.FieldPacket[]) => any): mysql.Query;
1111
ping(callback?: (err: mysql.QueryError | null) => any): void;
12+
promise(promiseImpl?: PromiseConstructor): PromiseConnection;
1213
}
1314

14-
export interface PoolConnection extends mysql.PoolConnection, Connection {}
15+
export interface PoolConnection extends mysql.PoolConnection, Connection {
16+
promise(promiseImpl?: PromiseConstructor): PromisePoolConnection;
17+
}
1518

1619
export interface Pool extends mysql.Connection {
1720
execute<T extends mysql.RowDataPacket[][] | mysql.RowDataPacket[] | mysql.OkPacket | mysql.OkPacket[]>(sql: string, callback?: (err: mysql.QueryError | null, result: T, fields: mysql.FieldPacket[]) => any): mysql.Query;
@@ -23,6 +26,7 @@ export interface Pool extends mysql.Connection {
2326
on(event: 'acquire', listener: (connection: PoolConnection) => any): this;
2427
on(event: 'release', listener: (connection: PoolConnection) => any): this;
2528
on(event: 'enqueue', listener: () => any): this;
29+
promise(promiseImpl?: PromiseConstructor): PromisePool;
2630
}
2731

2832
export interface ConnectionOptions extends mysql.ConnectionOptions {

0 commit comments

Comments
 (0)