mm_mysql 2.4.0 → 2.4.1
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.js +1 -29
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -417,7 +417,7 @@ Mysql.prototype.getPoolStats = function () {
|
|
|
417
417
|
*/
|
|
418
418
|
Mysql.prototype.healthCheck = async function () {
|
|
419
419
|
try {
|
|
420
|
-
if (!this._pool && !this.
|
|
420
|
+
if (!this._pool && !this._conneced) {
|
|
421
421
|
return {
|
|
422
422
|
status: 'error',
|
|
423
423
|
message: '数据库连接未初始化'
|
|
@@ -479,34 +479,6 @@ if (!$.pool.mysql) {
|
|
|
479
479
|
$.pool.mysql = {};
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
-
/**
|
|
483
|
-
* 全局锁对象,用于线程安全
|
|
484
|
-
*/
|
|
485
|
-
if (!$.pool.mysql._locks) {
|
|
486
|
-
$.pool.mysql._locks = {};
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
/**
|
|
490
|
-
* 获取锁
|
|
491
|
-
* @param {string} key - 锁的键名
|
|
492
|
-
* @returns {Promise<Function>} 释放锁的函数
|
|
493
|
-
*/
|
|
494
|
-
function _acquireLock(key) {
|
|
495
|
-
if (!$.pool.mysql._locks[key]) {
|
|
496
|
-
$.pool.mysql._locks[key] = Promise.resolve();
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
let release;
|
|
500
|
-
let lockPromise = $.pool.mysql._locks[key].then(() => {
|
|
501
|
-
return new Promise(resolve => {
|
|
502
|
-
release = resolve;
|
|
503
|
-
});
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
$.pool.mysql._locks[key] = lockPromise;
|
|
507
|
-
return lockPromise.then(() => release);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
482
|
/**
|
|
511
483
|
* @description Mysql管理器,用于创建缓存(线程安全版)
|
|
512
484
|
* @param {string} scope 作用域
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_mysql",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "这是超级美眉mysql帮助函数模块,用于便捷操作mysql,使用await方式,可以避免嵌套函数",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"mm_expand": "^2.2.
|
|
8
|
-
"mysql2": "^3.22.
|
|
7
|
+
"mm_expand": "^2.2.9",
|
|
8
|
+
"mysql2": "^3.22.3",
|
|
9
9
|
"sqlstring": "^2.3.3"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"node": ">=12.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"eslint": "^10.2.
|
|
39
|
+
"eslint": "^10.2.1",
|
|
40
40
|
"eslint-plugin-jsdoc": "^62.9.0",
|
|
41
41
|
"mm_eslint": "^1.7.1"
|
|
42
42
|
}
|