@stashfin/mysql2 1.3.3 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -2
- package/index.js +1 -7
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import mysql, { RowDataPacket, PoolOptions, ResultSetHeader } from 'mysql2';
|
|
2
|
-
import { Connection } from 'mysql2/typings/mysql/lib/Connection';
|
|
3
2
|
export interface MysqlConnectorOptions extends PoolOptions {
|
|
4
3
|
}
|
|
5
4
|
export declare class MysqlConnector {
|
|
@@ -8,7 +7,7 @@ export declare class MysqlConnector {
|
|
|
8
7
|
constructor(credentials: PoolOptions);
|
|
9
8
|
/** A random method to simulate a step before to get the class methods */
|
|
10
9
|
getPoolConnection(): mysql.Pool;
|
|
11
|
-
getConnection(): Promise<
|
|
10
|
+
getConnection(): Promise<import("mysql2/promise").PoolConnection>;
|
|
12
11
|
queryRow<T extends RowDataPacket>(sql: string, values?: Array<string | number>): Promise<T | undefined>;
|
|
13
12
|
queryRows<T extends RowDataPacket>(sql: string, values?: Array<string | number>): Promise<T[]>;
|
|
14
13
|
queryArray<T extends RowDataPacket>(sql: string, values?: Array<string | number>): Promise<T[]>;
|
package/index.js
CHANGED
|
@@ -22,13 +22,7 @@ class MysqlConnector {
|
|
|
22
22
|
getConnection() {
|
|
23
23
|
if (!this?.pool)
|
|
24
24
|
this.pool = mysql2_1.default.createPool(this.credentials);
|
|
25
|
-
return
|
|
26
|
-
this.pool.getConnection((err, connection) => {
|
|
27
|
-
if (err)
|
|
28
|
-
reject(err);
|
|
29
|
-
resolve(connection);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
25
|
+
return this.pool.promise().getConnection();
|
|
32
26
|
}
|
|
33
27
|
async queryRow(sql, values) {
|
|
34
28
|
const pool = this.getPoolConnection();
|