@naturalcycles/mysql-lib 3.12.2 → 3.12.3
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/dist/mysql.db.js +7 -7
- package/package.json +1 -1
- package/src/mysql.db.ts +3 -3
package/dist/mysql.db.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MysqlDB = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const node_stream_1 = require("node:stream");
|
|
6
|
+
const node_util_1 = require("node:util");
|
|
7
7
|
const db_lib_1 = require("@naturalcycles/db-lib");
|
|
8
8
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
9
9
|
const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
|
|
@@ -75,7 +75,7 @@ class MysqlDB extends db_lib_1.BaseCommonDB {
|
|
|
75
75
|
async close() {
|
|
76
76
|
const pool = this.pool();
|
|
77
77
|
// eslint-disable-next-line @typescript-eslint/await-thenable
|
|
78
|
-
await (0,
|
|
78
|
+
await (0, node_util_1.promisify)(pool.end.bind(pool))();
|
|
79
79
|
this.cfg.logger.log('closed');
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
@@ -83,7 +83,7 @@ class MysqlDB extends db_lib_1.BaseCommonDB {
|
|
|
83
83
|
*/
|
|
84
84
|
async getConnection() {
|
|
85
85
|
const pool = this.pool();
|
|
86
|
-
return await (0,
|
|
86
|
+
return await (0, node_util_1.promisify)(pool.getConnection.bind(pool))();
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* Manually create a single (not pool) connection.
|
|
@@ -91,7 +91,7 @@ class MysqlDB extends db_lib_1.BaseCommonDB {
|
|
|
91
91
|
*/
|
|
92
92
|
async createSingleConnection() {
|
|
93
93
|
const con = mysql.createConnection(this.cfg);
|
|
94
|
-
await (0,
|
|
94
|
+
await (0, node_util_1.promisify)(con.connect.bind(con))();
|
|
95
95
|
const { threadId } = con;
|
|
96
96
|
if (this.cfg.debugConnections) {
|
|
97
97
|
this.cfg.logger.log(`createSingleConnection(${threadId})`);
|
|
@@ -163,7 +163,7 @@ class MysqlDB extends db_lib_1.BaseCommonDB {
|
|
|
163
163
|
streamQuery(q, _opt = {}) {
|
|
164
164
|
const sql = (0, query_util_1.dbQueryToSQLSelect)(q);
|
|
165
165
|
if (!sql) {
|
|
166
|
-
return
|
|
166
|
+
return node_stream_1.Readable.from([]);
|
|
167
167
|
}
|
|
168
168
|
if (this.cfg.logSQL)
|
|
169
169
|
this.cfg.logger.log(`stream: ${sql}`);
|
|
@@ -171,7 +171,7 @@ class MysqlDB extends db_lib_1.BaseCommonDB {
|
|
|
171
171
|
return this.pool()
|
|
172
172
|
.query(sql)
|
|
173
173
|
.stream()
|
|
174
|
-
.pipe(new
|
|
174
|
+
.pipe(new node_stream_1.Transform({
|
|
175
175
|
objectMode: true,
|
|
176
176
|
transform(row, _encoding, cb) {
|
|
177
177
|
cb(null, (0, js_lib_1._filterUndefinedValues)(row, true));
|
package/package.json
CHANGED
package/src/mysql.db.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Readable, Transform } from 'stream'
|
|
2
|
-
import { promisify } from 'util'
|
|
1
|
+
import { Readable, Transform } from 'node:stream'
|
|
2
|
+
import { promisify } from 'node:util'
|
|
3
3
|
import {
|
|
4
4
|
BaseCommonDB,
|
|
5
5
|
CommonDB,
|
|
@@ -325,7 +325,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB {
|
|
|
325
325
|
/**
|
|
326
326
|
* Limitation: always returns [], regardless of which rows are actually deleted
|
|
327
327
|
*/
|
|
328
|
-
|
|
328
|
+
async deleteByIds<ROW extends ObjectWithId>(
|
|
329
329
|
table: string,
|
|
330
330
|
ids: ROW['id'][],
|
|
331
331
|
_opt?: MysqlDBOptions,
|