mm_mysql 1.9.9 → 2.0.0
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 +5 -2
- package/package.json +1 -1
- package/test.js +1 -1
package/index.js
CHANGED
|
@@ -94,7 +94,7 @@ class Mysql {
|
|
|
94
94
|
var list = [];
|
|
95
95
|
try {
|
|
96
96
|
// 关于连接池初始化,请参阅上文
|
|
97
|
-
conn = await $this.
|
|
97
|
+
conn = await $this.getConn();
|
|
98
98
|
const [rows] = await conn.query(sql, val);
|
|
99
99
|
// 查询解析时,连接会自动释放
|
|
100
100
|
list = rows;
|
|
@@ -138,7 +138,7 @@ class Mysql {
|
|
|
138
138
|
var conn;
|
|
139
139
|
var bl = -1;
|
|
140
140
|
try {
|
|
141
|
-
conn = await $this.
|
|
141
|
+
conn = await $this.getConn();
|
|
142
142
|
var [rows] = await conn.execute(sql, val);
|
|
143
143
|
if (rows.constructor == Array) {
|
|
144
144
|
if (rows.length > 0) {
|
|
@@ -188,6 +188,9 @@ class Mysql {
|
|
|
188
188
|
Mysql.prototype.getConn = async function() {
|
|
189
189
|
let conn;
|
|
190
190
|
try {
|
|
191
|
+
if (!this.pool) {
|
|
192
|
+
await this.open();
|
|
193
|
+
}
|
|
191
194
|
conn = await this.pool.getConnection();
|
|
192
195
|
} catch (err) {
|
|
193
196
|
console.error('Connection failed - retrying: ' + err.message);
|
package/package.json
CHANGED