mm_mysql 2.0.5 → 2.0.7

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.
Files changed (3) hide show
  1. package/db.js +1 -1
  2. package/index.js +7 -4
  3. package/package.json +3 -2
package/db.js CHANGED
@@ -127,7 +127,7 @@ DB.prototype.exec = async function(sql, timeout = 30000) {
127
127
  * @param {Number} timeout 超时时间(毫秒)
128
128
  * @returns {Promise<Object>} 数据库连接对象
129
129
  */
130
- DB.prototype.getConn = async function(timeout = 15000) {
130
+ DB.prototype.getConn = async function(timeout = 30000) {
131
131
  if (!this._mysql) {
132
132
  throw new Error('MySQL实例未初始化');
133
133
  }
package/index.js CHANGED
@@ -10,6 +10,11 @@ const { DB } = require('./db');
10
10
  class Mysql extends BaseService {
11
11
  /**
12
12
  * 默认配置
13
+ * MySQL2支持的连接池配置参数:
14
+ * - host, port, user, password, database
15
+ * - charset, timezone, connectTimeout
16
+ * - connectionLimit, acquireTimeout, waitForConnections
17
+ * - queueLimit参数在MySQL2中可能不被支持,已移除
13
18
  */
14
19
  static default_config = {
15
20
  host: '127.0.0.1',
@@ -20,10 +25,8 @@ class Mysql extends BaseService {
20
25
  charset: 'utf8mb4',
21
26
  timezone: '+08:00',
22
27
  connectTimeout: 20000,
23
- acquireTimeout: 20000,
24
- queryTimeout: 20000,
25
- connectionLimit: 10,
26
- queueLimit: 0
28
+ connectionLimit: 10
29
+ // queueLimit: 0 // MySQL2不支持此参数,已移除以避免警告
27
30
  };
28
31
 
29
32
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_mysql",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "这是超级美眉mysql帮助函数模块,用于便捷操作mysql,使用await方式,可以避免嵌套函数",
5
5
  "main": "index.js",
6
6
  "dependencies": {
@@ -8,7 +8,8 @@
8
8
  "mysql2": "^3.15.2"
9
9
  },
10
10
  "scripts": {
11
- "start": "node index.js"
11
+ "start": "node index.js",
12
+ "test": "node test.js"
12
13
  },
13
14
  "repository": {
14
15
  "type": "git",