mm_sql 1.4.1 → 1.4.2
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/README.md +2 -0
- package/admin_vs_direct_test.js +162 -0
- package/compatibility_test.js +320 -0
- package/comprehensive_test.js +304 -0
- package/db/mm.db +0 -0
- package/debug_error_test.js +127 -0
- package/debug_test.js +35 -0
- package/debug_test2.js +45 -0
- package/debug_test3.js +54 -0
- package/detailed_error_test.js +133 -0
- package/eslint.config.js +235 -0
- package/index.js +306 -297
- package/mysql_error_test.js +110 -0
- package/package.json +13 -5
- package/test.js +271 -222
- package/test2.js +53 -49
package/test.js
CHANGED
|
@@ -1,255 +1,304 @@
|
|
|
1
1
|
const { Sql } = require('./index.js');
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Sql类测试
|
|
5
5
|
*/
|
|
6
6
|
class SqlTest {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
constructor() {
|
|
8
|
+
console.log('SqlTest构造函数开始执行');
|
|
9
|
+
this.sql = null;
|
|
10
|
+
this.count = 0;
|
|
11
|
+
this.success = 0;
|
|
12
|
+
console.log('SqlTest构造函数执行完毕');
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
15
|
+
/**
|
|
16
|
+
* 初始化测试
|
|
17
|
+
* @returns {Promise<boolean>} 初始化结果
|
|
18
|
+
*/
|
|
19
|
+
async init() {
|
|
20
|
+
try {
|
|
21
|
+
this.sql = new Sql({
|
|
22
|
+
// db_type: 'mysql',
|
|
23
|
+
db_type: 'sqlite',
|
|
24
|
+
dir: './db',
|
|
25
|
+
host: 'localhost',
|
|
26
|
+
user: 'root',
|
|
27
|
+
password: 'Asd159357',
|
|
28
|
+
database: 'mm'
|
|
29
|
+
});
|
|
30
|
+
console.log('初始化测试成功');
|
|
31
|
+
return true;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error('初始化测试失败:', error.message);
|
|
34
|
+
return false;
|
|
35
35
|
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 测试配置方法
|
|
40
|
+
* @returns {boolean} 测试结果
|
|
41
|
+
*/
|
|
42
|
+
testConfigMethods() {
|
|
43
|
+
this.count++;
|
|
44
|
+
try {
|
|
45
|
+
// 测试setConfig方法
|
|
46
|
+
this.sql.setConfig({ size: 50 });
|
|
47
|
+
if (this.sql.config.size !== 50) {
|
|
48
|
+
throw new Error('setConfig方法测试失败');
|
|
49
|
+
}
|
|
36
50
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (this.sql.config.size !== 50) {
|
|
46
|
-
throw new Error('setConfig方法测试失败');
|
|
47
|
-
}
|
|
51
|
+
console.log('配置方法测试成功');
|
|
52
|
+
this.success++;
|
|
53
|
+
return true;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error('配置方法测试失败:', error.message);
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
48
59
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
/**
|
|
61
|
+
* 测试SQL构建方法
|
|
62
|
+
* @returns {boolean} 测试结果
|
|
63
|
+
*/
|
|
64
|
+
testSqlBuild() {
|
|
65
|
+
this.count++;
|
|
66
|
+
try {
|
|
67
|
+
console.log('SQL构建方法测试成功');
|
|
68
|
+
this.success++;
|
|
69
|
+
return true;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error('SQL构建方法测试失败:', error.message);
|
|
72
|
+
return false;
|
|
56
73
|
}
|
|
74
|
+
}
|
|
57
75
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
/**
|
|
77
|
+
* 测试基本tplQuery方法
|
|
78
|
+
* @private
|
|
79
|
+
* @returns {boolean} 测试结果
|
|
80
|
+
*/
|
|
81
|
+
_testBasicTplQuery() {
|
|
82
|
+
console.log('=== 测试tplQuery方法 ===');
|
|
83
|
+
const param = {
|
|
84
|
+
name: '张三',
|
|
85
|
+
uid: 123
|
|
86
|
+
};
|
|
87
|
+
const sql_tpl = {
|
|
88
|
+
name: "`name` like '%{0}%'",
|
|
89
|
+
uid: '`uid` = {0}'
|
|
90
|
+
};
|
|
91
|
+
const query = this.sql.tplQuery(param, sql_tpl);
|
|
92
|
+
console.log('tplQuery输入参数:', param);
|
|
93
|
+
console.log('tplQuery模板配置:', sql_tpl);
|
|
94
|
+
console.log('tplQuery输出结果:', query);
|
|
95
|
+
if (typeof query !== 'string') {
|
|
96
|
+
throw new Error('tplQuery方法应返回字符串');
|
|
71
97
|
}
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
72
100
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
/**
|
|
102
|
+
* 测试基本tplBody方法
|
|
103
|
+
* @private
|
|
104
|
+
* @returns {boolean} 测试结果
|
|
105
|
+
*/
|
|
106
|
+
_testBasicTplBody() {
|
|
107
|
+
console.log('\n=== 测试tplBody方法 ===');
|
|
108
|
+
const param2 = {
|
|
109
|
+
name: '李四',
|
|
110
|
+
phone: '13800138000'
|
|
111
|
+
};
|
|
112
|
+
const sql_tpl2 = {
|
|
113
|
+
name: '`name` = {0}'
|
|
114
|
+
};
|
|
115
|
+
const body = this.sql.tplBody(param2, sql_tpl2);
|
|
116
|
+
console.log('tplBody输入参数:', param2);
|
|
117
|
+
console.log('tplBody模板配置:', sql_tpl2);
|
|
118
|
+
console.log('tplBody输出结果:', body);
|
|
119
|
+
if (typeof body !== 'string') {
|
|
120
|
+
throw new Error('tplBody方法应返回字符串');
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
96
124
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
125
|
+
/**
|
|
126
|
+
* 测试复杂tplQuery方法
|
|
127
|
+
* @private
|
|
128
|
+
* @returns {boolean} 测试结果
|
|
129
|
+
*/
|
|
130
|
+
_testComplexTplQuery() {
|
|
131
|
+
console.log('\n=== 测试tplQuery方法(复杂条件)===');
|
|
132
|
+
const complex_param = {
|
|
133
|
+
name: '王五',
|
|
134
|
+
age: 30,
|
|
135
|
+
email: 'wangwu@example.com'
|
|
136
|
+
};
|
|
137
|
+
const complex_sql_tpl = {
|
|
138
|
+
name: "(`name` like '%{0}%' OR `nickname` like '%{0}%')",
|
|
139
|
+
age: '`age` >= {0}'
|
|
140
|
+
};
|
|
141
|
+
const complex_query = this.sql.tplQuery(complex_param, complex_sql_tpl);
|
|
142
|
+
console.log('复杂条件tplQuery输入参数:', complex_param);
|
|
143
|
+
console.log('复杂条件tplQuery模板配置:', complex_sql_tpl);
|
|
144
|
+
console.log('复杂条件tplQuery输出结果:', complex_query);
|
|
145
|
+
if (typeof complex_query !== 'string') {
|
|
146
|
+
throw new Error('tplQuery方法(复杂条件)应返回字符串');
|
|
147
|
+
}
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
113
150
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
151
|
+
/**
|
|
152
|
+
* 测试复杂tplBody方法
|
|
153
|
+
* @private
|
|
154
|
+
* @returns {boolean} 测试结果
|
|
155
|
+
*/
|
|
156
|
+
_testComplexTplBody() {
|
|
157
|
+
console.log('\n=== 测试tplBody方法(复杂更新)===');
|
|
158
|
+
const complex_param2 = {
|
|
159
|
+
name: '赵六',
|
|
160
|
+
age: 35,
|
|
161
|
+
score: 95
|
|
162
|
+
};
|
|
163
|
+
const complex_sql_tpl2 = {
|
|
164
|
+
age: '`age` = `age` + {0}',
|
|
165
|
+
score: '`score` = {0}'
|
|
166
|
+
};
|
|
167
|
+
const complex_body = this.sql.tplBody(complex_param2, complex_sql_tpl2);
|
|
168
|
+
console.log('复杂更新tplBody输入参数:', complex_param2);
|
|
169
|
+
console.log('复杂更新tplBody模板配置:', complex_sql_tpl2);
|
|
170
|
+
console.log('复杂更新tplBody输出结果:', complex_body);
|
|
171
|
+
if (typeof complex_body !== 'string') {
|
|
172
|
+
throw new Error('tplBody方法(复杂更新)应返回字符串');
|
|
173
|
+
}
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
132
176
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const complexBodyResult = this.sql.tplBody(complexParamDt2, complexSqlDt2);
|
|
145
|
-
console.log('复杂更新tplBody输入参数:', complexParamDt2);
|
|
146
|
-
console.log('复杂更新tplBody模板配置:', complexSqlDt2);
|
|
147
|
-
console.log('复杂更新tplBody输出结果:', complexBodyResult);
|
|
148
|
-
if (typeof complexBodyResult !== 'string') {
|
|
149
|
-
throw new Error('tplBody方法(复杂更新)应返回字符串');
|
|
150
|
-
}
|
|
177
|
+
/**
|
|
178
|
+
* 测试模板查询方法
|
|
179
|
+
* @returns {boolean} 测试结果
|
|
180
|
+
*/
|
|
181
|
+
testTplQuery() {
|
|
182
|
+
this.count++;
|
|
183
|
+
try {
|
|
184
|
+
this._testBasicTplQuery();
|
|
185
|
+
this._testBasicTplBody();
|
|
186
|
+
this._testComplexTplQuery();
|
|
187
|
+
this._testComplexTplBody();
|
|
151
188
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
189
|
+
console.log('\n模板查询方法测试成功');
|
|
190
|
+
this.success++;
|
|
191
|
+
return true;
|
|
192
|
+
} catch (error) {
|
|
193
|
+
console.error('模板查询方法测试失败:', error.message);
|
|
194
|
+
return false;
|
|
159
195
|
}
|
|
196
|
+
}
|
|
160
197
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
198
|
+
/**
|
|
199
|
+
* 测试数据库操作方法
|
|
200
|
+
* @private
|
|
201
|
+
* @param {object} db - 数据库实例
|
|
202
|
+
* @returns {Promise} 测试结果
|
|
203
|
+
*/
|
|
204
|
+
async _testDbOperations(db) {
|
|
205
|
+
await db.createTable('user_account', {
|
|
206
|
+
user_id: 1,
|
|
207
|
+
username: '',
|
|
208
|
+
password: '',
|
|
209
|
+
gm: 1,
|
|
210
|
+
vip: 0
|
|
211
|
+
}, 'user_id');
|
|
212
|
+
console.log('创建表成功');
|
|
171
213
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
throw new Error('exec方法不存在');
|
|
175
|
-
}
|
|
214
|
+
const fields = await db.fields('user_account');
|
|
215
|
+
console.log('查询字段:', fields);
|
|
176
216
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
217
|
+
// 设置表名后执行查询
|
|
218
|
+
const db_inst = db;
|
|
219
|
+
db_inst.table = 'user_account';
|
|
220
|
+
const result = await db_inst.get({
|
|
221
|
+
user_id: '1'
|
|
222
|
+
});
|
|
223
|
+
console.log('查询结果:', result);
|
|
224
|
+
console.log('调试DB:查询方法测试完成后', db_inst.sql, db_inst.error);
|
|
225
|
+
}
|
|
181
226
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
227
|
+
/**
|
|
228
|
+
* 测试核心方法(run、exec、db)
|
|
229
|
+
* @returns {boolean} 测试结果
|
|
230
|
+
*/
|
|
231
|
+
async testCoreMethods() {
|
|
232
|
+
this.count++;
|
|
233
|
+
try {
|
|
234
|
+
// 测试run方法存在
|
|
235
|
+
if (typeof this.sql.run !== 'function') {
|
|
236
|
+
throw new Error('run方法不存在');
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// 测试exec方法存在
|
|
240
|
+
if (typeof this.sql.exec !== 'function') {
|
|
241
|
+
throw new Error('exec方法不存在');
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// 测试db方法存在
|
|
245
|
+
if (typeof this.sql.db !== 'function') {
|
|
246
|
+
throw new Error('db方法不存在');
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// 测试db方法返回值
|
|
250
|
+
const db = this.sql.db();
|
|
251
|
+
if (!db) {
|
|
252
|
+
throw new Error('db方法返回值无效');
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
await this._testDbOperations(db);
|
|
256
|
+
console.log('核心方法测试成功');
|
|
257
|
+
this.success++;
|
|
258
|
+
return true;
|
|
259
|
+
} catch (error) {
|
|
260
|
+
console.error('核心方法测试失败:', error.message);
|
|
261
|
+
return false;
|
|
215
262
|
}
|
|
263
|
+
}
|
|
216
264
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
265
|
+
/**
|
|
266
|
+
* 运行所有测试
|
|
267
|
+
* @returns {Promise<boolean>} 测试结果
|
|
268
|
+
*/
|
|
269
|
+
async runAllTests() {
|
|
270
|
+
console.log('开始运行Sql类测试...');
|
|
271
|
+
console.log('='.repeat(50));
|
|
272
|
+
console.log('测试开始前');
|
|
224
273
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
274
|
+
// 初始化测试
|
|
275
|
+
if (!await this.init()) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
229
278
|
|
|
230
|
-
|
|
279
|
+
console.log('调试:初始化完成后');
|
|
231
280
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
281
|
+
// 运行所有测试方法
|
|
282
|
+
this.testConfigMethods();
|
|
283
|
+
console.log('调试:配置方法测试完成后');
|
|
284
|
+
this.testSqlBuild();
|
|
285
|
+
console.log('调试:SQL构建方法测试完成后');
|
|
286
|
+
this.testTplQuery();
|
|
287
|
+
console.log('调试:模板查询方法测试完成后');
|
|
288
|
+
this.testCoreMethods();
|
|
289
|
+
console.log('调试:核心方法测试完成后');
|
|
241
290
|
|
|
242
|
-
|
|
243
|
-
|
|
291
|
+
console.log('='.repeat(50));
|
|
292
|
+
console.log(`测试完成: ${this.success}/${this.count} 个测试通过`);
|
|
244
293
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
294
|
+
if (this.success === this.count) {
|
|
295
|
+
console.log('所有测试通过!');
|
|
296
|
+
return true;
|
|
297
|
+
} else {
|
|
298
|
+
console.log('部分测试失败!');
|
|
299
|
+
return false;
|
|
252
300
|
}
|
|
301
|
+
}
|
|
253
302
|
}
|
|
254
303
|
|
|
255
304
|
// 运行测试
|
package/test2.js
CHANGED
|
@@ -1,60 +1,64 @@
|
|
|
1
1
|
const { Sql } = require('./index.js');
|
|
2
|
+
/**
|
|
3
|
+
* 测试函数
|
|
4
|
+
* @returns {Promise<void>}
|
|
5
|
+
*/
|
|
2
6
|
async function test() {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
const sql = new Sql({
|
|
8
|
+
// 数据库类型 mysql, sqlite, postgres
|
|
9
|
+
db_type: 'sqlite',
|
|
10
|
+
dir: '/db/',
|
|
11
|
+
user: 'root',
|
|
12
|
+
password: 'Asd159357',
|
|
13
|
+
database: 'mm'
|
|
14
|
+
});
|
|
15
|
+
await sql.open();
|
|
16
|
+
// const result = await sql.run("SELECT * FROM user_account limit 10");
|
|
17
|
+
// console.log("查询结果:", result);
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
const db = sql.db();
|
|
20
|
+
db.table = 'user_account';
|
|
21
|
+
// 添加表
|
|
22
|
+
const res = await db.addTable('user_account', 'user_id');
|
|
23
|
+
console.log('添加表结果:', res);
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
// 添加字段(不需要指定表名,因为已通过db.table设置)
|
|
26
|
+
const res2 = await db.addField('age', 'INT', '0');
|
|
27
|
+
const res3 = await db.addField('sex', 'INT', '0');
|
|
28
|
+
console.log('添加字段结果:', res2, res3);
|
|
29
|
+
db.key = 'user_id';
|
|
30
|
+
const user = await db.getObj({
|
|
31
|
+
user_id: 1
|
|
32
|
+
});
|
|
29
33
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
34
|
+
if (!user) {
|
|
35
|
+
// 如果用户不存在,创建一个新用户
|
|
36
|
+
user = {
|
|
37
|
+
user_id: 1,
|
|
38
|
+
vip: 5,
|
|
39
|
+
gm: 5
|
|
40
|
+
};
|
|
41
|
+
await db.add(user);
|
|
42
|
+
} else {
|
|
43
|
+
// 如果用户存在,更新其属性
|
|
44
|
+
user.vip = 5;
|
|
45
|
+
user.gm = 5;
|
|
46
|
+
await db.set({ user_id: 1 }, user);
|
|
47
|
+
}
|
|
48
|
+
// 使用原生的setTimeout实现延迟
|
|
49
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
50
|
+
db.size = 1;
|
|
51
|
+
const list = await db.get({
|
|
52
|
+
user_id: 1
|
|
53
|
+
});
|
|
54
|
+
console.log('查询结果:', list);
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
// 调用test函数并处理异常
|
|
54
58
|
test().catch(err => {
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
console.error('测试过程中发生错误:', err);
|
|
60
|
+
process.exit(1);
|
|
57
61
|
}).finally(() => {
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
// 确保程序以零退出码结束
|
|
63
|
+
process.exit(0);
|
|
60
64
|
});
|