baja-lite 1.0.21 → 1.0.22
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/cjs/code.js +27 -24
- package/cjs/sql.js +57 -39
- package/es/code.js +27 -24
- package/es/sql.js +57 -39
- package/package.json +3 -3
- package/src/code.ts +26 -23
- package/src/sql.ts +55 -33
package/cjs/code.js
CHANGED
|
@@ -278,33 +278,36 @@ try {
|
|
|
278
278
|
return;
|
|
279
279
|
}
|
|
280
280
|
const txt = mustache_1.default.render(template, data, {}, ['<%', '%>']);
|
|
281
|
-
const
|
|
282
|
-
const
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
281
|
+
const _fileName = configData.command[command].replace(/{([a-zA-Z]+)}/g, (a, b) => data[b]);
|
|
282
|
+
const fileNames = _fileName.split(',');
|
|
283
|
+
for (const fileName of fileNames) {
|
|
284
|
+
const filePath = path_1.default.join(basepath, fileName);
|
|
285
|
+
const dirname = path_1.default.dirname(filePath);
|
|
286
|
+
(0, shelljs_1.mkdir)('-p', dirname);
|
|
287
|
+
// try {
|
|
288
|
+
// fs.statSync(dirname);
|
|
289
|
+
// } catch (error) {
|
|
290
|
+
// fs.mkdirSync(dirname);
|
|
291
|
+
// console.info(`[生成] ${dirname}`);
|
|
292
|
+
// }
|
|
293
|
+
try {
|
|
294
|
+
fs_1.default.statSync(filePath);
|
|
295
|
+
if (force === false) {
|
|
296
|
+
console.warn(`[跳过] ${filePath}`);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
console.warn(`[覆盖] ${filePath}`);
|
|
301
|
+
}
|
|
296
302
|
}
|
|
297
|
-
|
|
298
|
-
console.
|
|
303
|
+
catch (error) {
|
|
304
|
+
console.info(`[生成] ${filePath}`);
|
|
299
305
|
}
|
|
306
|
+
if (configData.output) {
|
|
307
|
+
outputs.add(configData.output.replace(/{([a-zA-Z]+)}/g, (a, b) => data[b]));
|
|
308
|
+
}
|
|
309
|
+
fs_1.default.writeFileSync(path_1.default.join(basepath, fileName), txt);
|
|
300
310
|
}
|
|
301
|
-
catch (error) {
|
|
302
|
-
console.info(`[生成] ${filePath}`);
|
|
303
|
-
}
|
|
304
|
-
if (configData.output) {
|
|
305
|
-
outputs.add(configData.output.replace(/{([a-zA-Z]+)}/g, (a, b) => data[b]));
|
|
306
|
-
}
|
|
307
|
-
fs_1.default.writeFileSync(path_1.default.join(basepath, fileName), txt);
|
|
308
311
|
}
|
|
309
312
|
}
|
|
310
313
|
const replServer = (0, repl_1.start)();
|
package/cjs/sql.js
CHANGED
|
@@ -2335,19 +2335,23 @@ class SqlService {
|
|
|
2335
2335
|
}, { everyLength: option?.every === true ? 1 : option?.maxDeal });
|
|
2336
2336
|
return result;
|
|
2337
2337
|
};
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
}
|
|
2338
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2339
|
+
return fn();
|
|
2340
|
+
}
|
|
2341
|
+
else {
|
|
2342
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn);
|
|
2343
|
+
}
|
|
2344
|
+
// return new Promise<bigint[]>(async (resolve, reject) => {
|
|
2345
|
+
// try {
|
|
2346
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2347
|
+
// resolve((await fn())!);
|
|
2348
|
+
// } else {
|
|
2349
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
2350
|
+
// }
|
|
2351
|
+
// } catch (error) {
|
|
2352
|
+
// reject(error);
|
|
2353
|
+
// }
|
|
2354
|
+
// });
|
|
2351
2355
|
}
|
|
2352
2356
|
else {
|
|
2353
2357
|
const fn = async () => {
|
|
@@ -2364,19 +2368,23 @@ class SqlService {
|
|
|
2364
2368
|
}, { everyLength: 1 });
|
|
2365
2369
|
return result[0];
|
|
2366
2370
|
};
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
}
|
|
2371
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2372
|
+
return fn();
|
|
2373
|
+
}
|
|
2374
|
+
else {
|
|
2375
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn);
|
|
2376
|
+
}
|
|
2377
|
+
// return new Promise<bigint>(async (resolve, reject) => {
|
|
2378
|
+
// try {
|
|
2379
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2380
|
+
// resolve((await fn())!);
|
|
2381
|
+
// } else {
|
|
2382
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
2383
|
+
// }
|
|
2384
|
+
// } catch (error) {
|
|
2385
|
+
// reject(error);
|
|
2386
|
+
// }
|
|
2387
|
+
// });
|
|
2380
2388
|
}
|
|
2381
2389
|
}
|
|
2382
2390
|
_update(datas, option) {
|
|
@@ -2452,6 +2460,12 @@ class SqlService {
|
|
|
2452
2460
|
}, { everyLength: option?.maxDeal });
|
|
2453
2461
|
return result.reduce((a, b) => a + b);
|
|
2454
2462
|
};
|
|
2463
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2464
|
+
return fn();
|
|
2465
|
+
}
|
|
2466
|
+
else {
|
|
2467
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn);
|
|
2468
|
+
}
|
|
2455
2469
|
return new Promise(async (resolve, reject) => {
|
|
2456
2470
|
try {
|
|
2457
2471
|
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
@@ -2571,19 +2585,23 @@ class SqlService {
|
|
|
2571
2585
|
}
|
|
2572
2586
|
return result;
|
|
2573
2587
|
};
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
}
|
|
2588
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2589
|
+
return fn();
|
|
2590
|
+
}
|
|
2591
|
+
else {
|
|
2592
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn);
|
|
2593
|
+
}
|
|
2594
|
+
// return new Promise<number>(async (resolve, reject) => {
|
|
2595
|
+
// try {
|
|
2596
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2597
|
+
// resolve((await fn())!);
|
|
2598
|
+
// } else {
|
|
2599
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
2600
|
+
// }
|
|
2601
|
+
// } catch (error) {
|
|
2602
|
+
// reject(error);
|
|
2603
|
+
// }
|
|
2604
|
+
// });
|
|
2587
2605
|
}
|
|
2588
2606
|
}
|
|
2589
2607
|
_template(templateResult, result, error) {
|
package/es/code.js
CHANGED
|
@@ -273,33 +273,36 @@ try {
|
|
|
273
273
|
return;
|
|
274
274
|
}
|
|
275
275
|
const txt = mustache.render(template, data, {}, ['<%', '%>']);
|
|
276
|
-
const
|
|
277
|
-
const
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
276
|
+
const _fileName = configData.command[command].replace(/{([a-zA-Z]+)}/g, (a, b) => data[b]);
|
|
277
|
+
const fileNames = _fileName.split(',');
|
|
278
|
+
for (const fileName of fileNames) {
|
|
279
|
+
const filePath = path.join(basepath, fileName);
|
|
280
|
+
const dirname = path.dirname(filePath);
|
|
281
|
+
mkdir('-p', dirname);
|
|
282
|
+
// try {
|
|
283
|
+
// fs.statSync(dirname);
|
|
284
|
+
// } catch (error) {
|
|
285
|
+
// fs.mkdirSync(dirname);
|
|
286
|
+
// console.info(`[生成] ${dirname}`);
|
|
287
|
+
// }
|
|
288
|
+
try {
|
|
289
|
+
fs.statSync(filePath);
|
|
290
|
+
if (force === false) {
|
|
291
|
+
console.warn(`[跳过] ${filePath}`);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
console.warn(`[覆盖] ${filePath}`);
|
|
296
|
+
}
|
|
291
297
|
}
|
|
292
|
-
|
|
293
|
-
console.
|
|
298
|
+
catch (error) {
|
|
299
|
+
console.info(`[生成] ${filePath}`);
|
|
294
300
|
}
|
|
301
|
+
if (configData.output) {
|
|
302
|
+
outputs.add(configData.output.replace(/{([a-zA-Z]+)}/g, (a, b) => data[b]));
|
|
303
|
+
}
|
|
304
|
+
fs.writeFileSync(path.join(basepath, fileName), txt);
|
|
295
305
|
}
|
|
296
|
-
catch (error) {
|
|
297
|
-
console.info(`[生成] ${filePath}`);
|
|
298
|
-
}
|
|
299
|
-
if (configData.output) {
|
|
300
|
-
outputs.add(configData.output.replace(/{([a-zA-Z]+)}/g, (a, b) => data[b]));
|
|
301
|
-
}
|
|
302
|
-
fs.writeFileSync(path.join(basepath, fileName), txt);
|
|
303
306
|
}
|
|
304
307
|
}
|
|
305
308
|
const replServer = start();
|
package/es/sql.js
CHANGED
|
@@ -2289,19 +2289,23 @@ export class SqlService {
|
|
|
2289
2289
|
}, { everyLength: option?.every === true ? 1 : option?.maxDeal });
|
|
2290
2290
|
return result;
|
|
2291
2291
|
};
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
}
|
|
2292
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2293
|
+
return fn();
|
|
2294
|
+
}
|
|
2295
|
+
else {
|
|
2296
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn);
|
|
2297
|
+
}
|
|
2298
|
+
// return new Promise<bigint[]>(async (resolve, reject) => {
|
|
2299
|
+
// try {
|
|
2300
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2301
|
+
// resolve((await fn())!);
|
|
2302
|
+
// } else {
|
|
2303
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
2304
|
+
// }
|
|
2305
|
+
// } catch (error) {
|
|
2306
|
+
// reject(error);
|
|
2307
|
+
// }
|
|
2308
|
+
// });
|
|
2305
2309
|
}
|
|
2306
2310
|
else {
|
|
2307
2311
|
const fn = async () => {
|
|
@@ -2318,19 +2322,23 @@ export class SqlService {
|
|
|
2318
2322
|
}, { everyLength: 1 });
|
|
2319
2323
|
return result[0];
|
|
2320
2324
|
};
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
}
|
|
2325
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2326
|
+
return fn();
|
|
2327
|
+
}
|
|
2328
|
+
else {
|
|
2329
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn);
|
|
2330
|
+
}
|
|
2331
|
+
// return new Promise<bigint>(async (resolve, reject) => {
|
|
2332
|
+
// try {
|
|
2333
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2334
|
+
// resolve((await fn())!);
|
|
2335
|
+
// } else {
|
|
2336
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
2337
|
+
// }
|
|
2338
|
+
// } catch (error) {
|
|
2339
|
+
// reject(error);
|
|
2340
|
+
// }
|
|
2341
|
+
// });
|
|
2334
2342
|
}
|
|
2335
2343
|
}
|
|
2336
2344
|
_update(datas, option) {
|
|
@@ -2406,6 +2414,12 @@ export class SqlService {
|
|
|
2406
2414
|
}, { everyLength: option?.maxDeal });
|
|
2407
2415
|
return result.reduce((a, b) => a + b);
|
|
2408
2416
|
};
|
|
2417
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2418
|
+
return fn();
|
|
2419
|
+
}
|
|
2420
|
+
else {
|
|
2421
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn);
|
|
2422
|
+
}
|
|
2409
2423
|
return new Promise(async (resolve, reject) => {
|
|
2410
2424
|
try {
|
|
2411
2425
|
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
@@ -2525,19 +2539,23 @@ export class SqlService {
|
|
|
2525
2539
|
}
|
|
2526
2540
|
return result;
|
|
2527
2541
|
};
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
}
|
|
2542
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2543
|
+
return fn();
|
|
2544
|
+
}
|
|
2545
|
+
else {
|
|
2546
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn);
|
|
2547
|
+
}
|
|
2548
|
+
// return new Promise<number>(async (resolve, reject) => {
|
|
2549
|
+
// try {
|
|
2550
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2551
|
+
// resolve((await fn())!);
|
|
2552
|
+
// } else {
|
|
2553
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
2554
|
+
// }
|
|
2555
|
+
// } catch (error) {
|
|
2556
|
+
// reject(error);
|
|
2557
|
+
// }
|
|
2558
|
+
// });
|
|
2541
2559
|
}
|
|
2542
2560
|
}
|
|
2543
2561
|
_template(templateResult, result, error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "baja-lite",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"description": "some util for self",
|
|
5
5
|
"homepage": "https://github.com/void-soul/util-man",
|
|
6
6
|
"repository": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"reflect-metadata": "0.2.2",
|
|
44
44
|
"sql-formatter": "15.4.0",
|
|
45
45
|
"sqlstring": "2.3.3",
|
|
46
|
-
"tslib": "2.
|
|
46
|
+
"tslib": "2.7.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/better-sqlite3": "7.6.11",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@types/sqlstring": "2.3.2",
|
|
53
53
|
"@typescript-eslint/eslint-plugin": "8.2.0",
|
|
54
54
|
"@typescript-eslint/parser": "8.2.0",
|
|
55
|
-
"better-sqlite3": "11.1
|
|
55
|
+
"better-sqlite3": "11.2.1",
|
|
56
56
|
"ioredis": "5.4.1",
|
|
57
57
|
"mongodb": "6.8.0",
|
|
58
58
|
"mysql2": "3.11.0",
|
package/src/code.ts
CHANGED
|
@@ -283,31 +283,34 @@ try {
|
|
|
283
283
|
return;
|
|
284
284
|
}
|
|
285
285
|
const txt = mustache.render(template, data, {}, ['<%', '%>']);
|
|
286
|
-
const
|
|
287
|
-
const
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
286
|
+
const _fileName = configData.command[command]!.replace(/{([a-zA-Z]+)}/g, (a: string, b: string) => data[b]);
|
|
287
|
+
const fileNames = _fileName.split(',');
|
|
288
|
+
for(const fileName of fileNames){
|
|
289
|
+
const filePath = path.join(basepath, fileName);
|
|
290
|
+
const dirname = path.dirname(filePath);
|
|
291
|
+
mkdir('-p', dirname);
|
|
292
|
+
// try {
|
|
293
|
+
// fs.statSync(dirname);
|
|
294
|
+
// } catch (error) {
|
|
295
|
+
// fs.mkdirSync(dirname);
|
|
296
|
+
// console.info(`[生成] ${dirname}`);
|
|
297
|
+
// }
|
|
298
|
+
try {
|
|
299
|
+
fs.statSync(filePath);
|
|
300
|
+
if (force === false) {
|
|
301
|
+
console.warn(`[跳过] ${filePath}`);
|
|
302
|
+
return;
|
|
303
|
+
} else {
|
|
304
|
+
console.warn(`[覆盖] ${filePath}`);
|
|
305
|
+
}
|
|
306
|
+
} catch (error) {
|
|
307
|
+
console.info(`[生成] ${filePath}`);
|
|
303
308
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
outputs.add(configData.output.replace(/{([a-zA-Z]+)}/g, (a: string, b: string) => data[b]));
|
|
309
|
+
if (configData.output) {
|
|
310
|
+
outputs.add(configData.output.replace(/{([a-zA-Z]+)}/g, (a: string, b: string) => data[b]));
|
|
311
|
+
}
|
|
312
|
+
fs.writeFileSync(path.join(basepath, fileName), txt);
|
|
309
313
|
}
|
|
310
|
-
fs.writeFileSync(path.join(basepath, fileName), txt);
|
|
311
314
|
}
|
|
312
315
|
}
|
|
313
316
|
const replServer = start();
|
package/src/sql.ts
CHANGED
|
@@ -2706,17 +2706,23 @@ export class SqlService<T extends object> {
|
|
|
2706
2706
|
);
|
|
2707
2707
|
return result;
|
|
2708
2708
|
};
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
}
|
|
2709
|
+
|
|
2710
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2711
|
+
return fn();
|
|
2712
|
+
} else {
|
|
2713
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn) as Promise<bigint[]>;
|
|
2714
|
+
}
|
|
2715
|
+
// return new Promise<bigint[]>(async (resolve, reject) => {
|
|
2716
|
+
// try {
|
|
2717
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2718
|
+
// resolve((await fn())!);
|
|
2719
|
+
// } else {
|
|
2720
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
2721
|
+
// }
|
|
2722
|
+
// } catch (error) {
|
|
2723
|
+
// reject(error);
|
|
2724
|
+
// }
|
|
2725
|
+
// });
|
|
2720
2726
|
} else {
|
|
2721
2727
|
const fn = async () => {
|
|
2722
2728
|
const result = await excuteSplit<Partial<T>, bigint>(
|
|
@@ -2735,17 +2741,22 @@ export class SqlService<T extends object> {
|
|
|
2735
2741
|
);
|
|
2736
2742
|
return result[0]!;
|
|
2737
2743
|
};
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2744
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2745
|
+
return fn();
|
|
2746
|
+
} else {
|
|
2747
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn) as Promise<bigint>;
|
|
2748
|
+
}
|
|
2749
|
+
// return new Promise<bigint>(async (resolve, reject) => {
|
|
2750
|
+
// try {
|
|
2751
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2752
|
+
// resolve((await fn())!);
|
|
2753
|
+
// } else {
|
|
2754
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
2755
|
+
// }
|
|
2756
|
+
// } catch (error) {
|
|
2757
|
+
// reject(error);
|
|
2758
|
+
// }
|
|
2759
|
+
// });
|
|
2749
2760
|
}
|
|
2750
2761
|
}
|
|
2751
2762
|
|
|
@@ -2852,6 +2863,12 @@ export class SqlService<T extends object> {
|
|
|
2852
2863
|
);
|
|
2853
2864
|
return result.reduce((a, b) => a + b);
|
|
2854
2865
|
};
|
|
2866
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2867
|
+
return fn();
|
|
2868
|
+
} else {
|
|
2869
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn) as Promise<number>;
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2855
2872
|
return new Promise<number>(async (resolve, reject) => {
|
|
2856
2873
|
try {
|
|
2857
2874
|
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
@@ -2998,17 +3015,22 @@ export class SqlService<T extends object> {
|
|
|
2998
3015
|
}
|
|
2999
3016
|
return result;
|
|
3000
3017
|
};
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3018
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
3019
|
+
return fn();
|
|
3020
|
+
} else {
|
|
3021
|
+
return option?.dao?.transaction<number>(SyncMode.Async, fn, option?.conn) as Promise<number>;
|
|
3022
|
+
}
|
|
3023
|
+
// return new Promise<number>(async (resolve, reject) => {
|
|
3024
|
+
// try {
|
|
3025
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
3026
|
+
// resolve((await fn())!);
|
|
3027
|
+
// } else {
|
|
3028
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
3029
|
+
// }
|
|
3030
|
+
// } catch (error) {
|
|
3031
|
+
// reject(error);
|
|
3032
|
+
// }
|
|
3033
|
+
// });
|
|
3012
3034
|
}
|
|
3013
3035
|
}
|
|
3014
3036
|
|