baja-lite 1.0.22 → 1.0.24
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/sql.d.ts +7 -0
- package/cjs/sql.js +19 -35
- package/es/sql.d.ts +7 -0
- package/es/sql.js +19 -35
- package/package.json +1 -1
- package/src/sql.ts +18 -30
package/cjs/sql.d.ts
CHANGED
|
@@ -491,6 +491,7 @@ export interface SqliteRemoteInterface {
|
|
|
491
491
|
initDB(dbName: string): Promise<void>;
|
|
492
492
|
export(dbName: string): Promise<void>;
|
|
493
493
|
restore(dbName: string, fromName: string): Promise<void>;
|
|
494
|
+
close(dbName?: string): void;
|
|
494
495
|
}
|
|
495
496
|
interface Connection {
|
|
496
497
|
[_daoConnection]: any;
|
|
@@ -1328,6 +1329,12 @@ export declare class SqlService<T extends object> {
|
|
|
1328
1329
|
sync: SyncMode.Sync;
|
|
1329
1330
|
force?: boolean;
|
|
1330
1331
|
}): void;
|
|
1332
|
+
close(option?: MethodOption & {
|
|
1333
|
+
sync?: SyncMode.Async;
|
|
1334
|
+
}): Promise<void>;
|
|
1335
|
+
close(option: MethodOption & {
|
|
1336
|
+
sync: SyncMode.Sync;
|
|
1337
|
+
}): void;
|
|
1331
1338
|
/**
|
|
1332
1339
|
#创建表
|
|
1333
1340
|
** `tableName` 表名称
|
package/cjs/sql.js
CHANGED
|
@@ -974,53 +974,21 @@ class SqliteRemote {
|
|
|
974
974
|
}
|
|
975
975
|
close(sync) {
|
|
976
976
|
if (sync === SyncMode.Async) {
|
|
977
|
-
return
|
|
978
|
-
try {
|
|
979
|
-
await this[_daoConnection].close();
|
|
980
|
-
}
|
|
981
|
-
catch (error) {
|
|
982
|
-
reject(error);
|
|
983
|
-
}
|
|
984
|
-
});
|
|
977
|
+
return this[_daoDB]?.close(this[_sqliteRemoteName]);
|
|
985
978
|
}
|
|
986
979
|
;
|
|
987
980
|
}
|
|
988
981
|
backup(sync, name) {
|
|
989
982
|
if (sync === SyncMode.Async) {
|
|
990
|
-
return
|
|
991
|
-
try {
|
|
992
|
-
await this[_daoConnection].backup(this[_sqliteRemoteName], name);
|
|
993
|
-
}
|
|
994
|
-
catch (error) {
|
|
995
|
-
reject(error);
|
|
996
|
-
}
|
|
997
|
-
});
|
|
983
|
+
return this[_daoDB]?.export(this[_sqliteRemoteName]);
|
|
998
984
|
}
|
|
999
985
|
;
|
|
1000
986
|
}
|
|
1001
987
|
remove(sync) {
|
|
1002
|
-
if (sync === SyncMode.Async) {
|
|
1003
|
-
return new Promise(async (resolve, reject) => {
|
|
1004
|
-
try {
|
|
1005
|
-
await this[_daoConnection].remove();
|
|
1006
|
-
}
|
|
1007
|
-
catch (error) {
|
|
1008
|
-
reject(error);
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
;
|
|
1013
988
|
}
|
|
1014
989
|
restore(sync, name) {
|
|
1015
990
|
if (sync === SyncMode.Async) {
|
|
1016
|
-
return
|
|
1017
|
-
try {
|
|
1018
|
-
await this[_daoConnection].restore(this[_sqliteRemoteName], name);
|
|
1019
|
-
}
|
|
1020
|
-
catch (error) {
|
|
1021
|
-
reject(error);
|
|
1022
|
-
}
|
|
1023
|
-
});
|
|
991
|
+
return this[_daoDB]?.restore(this[_sqliteRemoteName], name);
|
|
1024
992
|
}
|
|
1025
993
|
;
|
|
1026
994
|
}
|
|
@@ -3162,6 +3130,16 @@ class SqlService {
|
|
|
3162
3130
|
});
|
|
3163
3131
|
}
|
|
3164
3132
|
}
|
|
3133
|
+
close(option) {
|
|
3134
|
+
const dbName = option?.dbName ?? this[_daoDBName] ?? exports._primaryDB;
|
|
3135
|
+
delete globalThis[exports._dao][this[_dbType]][dbName];
|
|
3136
|
+
if (option?.sync === SyncMode.Async) {
|
|
3137
|
+
return option.dao.close(SyncMode.Async);
|
|
3138
|
+
}
|
|
3139
|
+
else if (option?.sync === SyncMode.Sync) {
|
|
3140
|
+
option.dao.close(SyncMode.Sync);
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3165
3143
|
/**
|
|
3166
3144
|
#创建表
|
|
3167
3145
|
** `tableName` 表名称
|
|
@@ -3323,6 +3301,12 @@ __decorate([
|
|
|
3323
3301
|
__metadata("design:paramtypes", [Object]),
|
|
3324
3302
|
__metadata("design:returntype", Object)
|
|
3325
3303
|
], SqlService.prototype, "init", null);
|
|
3304
|
+
__decorate([
|
|
3305
|
+
P(),
|
|
3306
|
+
__metadata("design:type", Function),
|
|
3307
|
+
__metadata("design:paramtypes", [Object]),
|
|
3308
|
+
__metadata("design:returntype", Object)
|
|
3309
|
+
], SqlService.prototype, "close", null);
|
|
3326
3310
|
/** 是否进行下一个动作 */
|
|
3327
3311
|
const IF_PROCEED = function () {
|
|
3328
3312
|
return function (_target, _propertyKey, descriptor) {
|
package/es/sql.d.ts
CHANGED
|
@@ -491,6 +491,7 @@ export interface SqliteRemoteInterface {
|
|
|
491
491
|
initDB(dbName: string): Promise<void>;
|
|
492
492
|
export(dbName: string): Promise<void>;
|
|
493
493
|
restore(dbName: string, fromName: string): Promise<void>;
|
|
494
|
+
close(dbName?: string): void;
|
|
494
495
|
}
|
|
495
496
|
interface Connection {
|
|
496
497
|
[_daoConnection]: any;
|
|
@@ -1328,6 +1329,12 @@ export declare class SqlService<T extends object> {
|
|
|
1328
1329
|
sync: SyncMode.Sync;
|
|
1329
1330
|
force?: boolean;
|
|
1330
1331
|
}): void;
|
|
1332
|
+
close(option?: MethodOption & {
|
|
1333
|
+
sync?: SyncMode.Async;
|
|
1334
|
+
}): Promise<void>;
|
|
1335
|
+
close(option: MethodOption & {
|
|
1336
|
+
sync: SyncMode.Sync;
|
|
1337
|
+
}): void;
|
|
1331
1338
|
/**
|
|
1332
1339
|
#创建表
|
|
1333
1340
|
** `tableName` 表名称
|
package/es/sql.js
CHANGED
|
@@ -932,53 +932,21 @@ export class SqliteRemote {
|
|
|
932
932
|
}
|
|
933
933
|
close(sync) {
|
|
934
934
|
if (sync === SyncMode.Async) {
|
|
935
|
-
return
|
|
936
|
-
try {
|
|
937
|
-
await this[_daoConnection].close();
|
|
938
|
-
}
|
|
939
|
-
catch (error) {
|
|
940
|
-
reject(error);
|
|
941
|
-
}
|
|
942
|
-
});
|
|
935
|
+
return this[_daoDB]?.close(this[_sqliteRemoteName]);
|
|
943
936
|
}
|
|
944
937
|
;
|
|
945
938
|
}
|
|
946
939
|
backup(sync, name) {
|
|
947
940
|
if (sync === SyncMode.Async) {
|
|
948
|
-
return
|
|
949
|
-
try {
|
|
950
|
-
await this[_daoConnection].backup(this[_sqliteRemoteName], name);
|
|
951
|
-
}
|
|
952
|
-
catch (error) {
|
|
953
|
-
reject(error);
|
|
954
|
-
}
|
|
955
|
-
});
|
|
941
|
+
return this[_daoDB]?.export(this[_sqliteRemoteName]);
|
|
956
942
|
}
|
|
957
943
|
;
|
|
958
944
|
}
|
|
959
945
|
remove(sync) {
|
|
960
|
-
if (sync === SyncMode.Async) {
|
|
961
|
-
return new Promise(async (resolve, reject) => {
|
|
962
|
-
try {
|
|
963
|
-
await this[_daoConnection].remove();
|
|
964
|
-
}
|
|
965
|
-
catch (error) {
|
|
966
|
-
reject(error);
|
|
967
|
-
}
|
|
968
|
-
});
|
|
969
|
-
}
|
|
970
|
-
;
|
|
971
946
|
}
|
|
972
947
|
restore(sync, name) {
|
|
973
948
|
if (sync === SyncMode.Async) {
|
|
974
|
-
return
|
|
975
|
-
try {
|
|
976
|
-
await this[_daoConnection].restore(this[_sqliteRemoteName], name);
|
|
977
|
-
}
|
|
978
|
-
catch (error) {
|
|
979
|
-
reject(error);
|
|
980
|
-
}
|
|
981
|
-
});
|
|
949
|
+
return this[_daoDB]?.restore(this[_sqliteRemoteName], name);
|
|
982
950
|
}
|
|
983
951
|
;
|
|
984
952
|
}
|
|
@@ -3116,6 +3084,16 @@ export class SqlService {
|
|
|
3116
3084
|
});
|
|
3117
3085
|
}
|
|
3118
3086
|
}
|
|
3087
|
+
close(option) {
|
|
3088
|
+
const dbName = option?.dbName ?? this[_daoDBName] ?? _primaryDB;
|
|
3089
|
+
delete globalThis[_dao][this[_dbType]][dbName];
|
|
3090
|
+
if (option?.sync === SyncMode.Async) {
|
|
3091
|
+
return option.dao.close(SyncMode.Async);
|
|
3092
|
+
}
|
|
3093
|
+
else if (option?.sync === SyncMode.Sync) {
|
|
3094
|
+
option.dao.close(SyncMode.Sync);
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3119
3097
|
/**
|
|
3120
3098
|
#创建表
|
|
3121
3099
|
** `tableName` 表名称
|
|
@@ -3276,6 +3254,12 @@ __decorate([
|
|
|
3276
3254
|
__metadata("design:paramtypes", [Object]),
|
|
3277
3255
|
__metadata("design:returntype", Object)
|
|
3278
3256
|
], SqlService.prototype, "init", null);
|
|
3257
|
+
__decorate([
|
|
3258
|
+
P(),
|
|
3259
|
+
__metadata("design:type", Function),
|
|
3260
|
+
__metadata("design:paramtypes", [Object]),
|
|
3261
|
+
__metadata("design:returntype", Object)
|
|
3262
|
+
], SqlService.prototype, "close", null);
|
|
3279
3263
|
/** 是否进行下一个动作 */
|
|
3280
3264
|
const IF_PROCEED = function () {
|
|
3281
3265
|
return function (_target, _propertyKey, descriptor) {
|
package/package.json
CHANGED
package/src/sql.ts
CHANGED
|
@@ -559,6 +559,7 @@ export interface SqliteRemoteInterface {
|
|
|
559
559
|
initDB(dbName: string): Promise<void>;
|
|
560
560
|
export(dbName: string): Promise<void>;
|
|
561
561
|
restore(dbName: string, fromName: string): Promise<void>;
|
|
562
|
+
close(dbName?: string): void;
|
|
562
563
|
};
|
|
563
564
|
interface Connection {
|
|
564
565
|
[_daoConnection]: any;
|
|
@@ -1277,13 +1278,7 @@ export class SqliteRemote implements Dao {
|
|
|
1277
1278
|
close(sync: SyncMode.Async): Promise<void>;
|
|
1278
1279
|
close(sync: SyncMode): Promise<void> | void {
|
|
1279
1280
|
if (sync === SyncMode.Async) {
|
|
1280
|
-
return
|
|
1281
|
-
try {
|
|
1282
|
-
await this[_daoConnection].close();
|
|
1283
|
-
} catch (error) {
|
|
1284
|
-
reject(error);
|
|
1285
|
-
}
|
|
1286
|
-
});
|
|
1281
|
+
return this[_daoDB]?.close(this[_sqliteRemoteName]);
|
|
1287
1282
|
};
|
|
1288
1283
|
}
|
|
1289
1284
|
|
|
@@ -1291,41 +1286,21 @@ export class SqliteRemote implements Dao {
|
|
|
1291
1286
|
backup(sync: SyncMode.Async, name: string): Promise<void>;
|
|
1292
1287
|
backup(sync: SyncMode, name: string): Promise<void> | void {
|
|
1293
1288
|
if (sync === SyncMode.Async) {
|
|
1294
|
-
return
|
|
1295
|
-
try {
|
|
1296
|
-
await this[_daoConnection].backup(this[_sqliteRemoteName], name);
|
|
1297
|
-
} catch (error) {
|
|
1298
|
-
reject(error);
|
|
1299
|
-
}
|
|
1300
|
-
});
|
|
1289
|
+
return this[_daoDB]?.export(this[_sqliteRemoteName]);
|
|
1301
1290
|
};
|
|
1302
1291
|
}
|
|
1303
1292
|
|
|
1304
1293
|
remove(sync: SyncMode.Sync): void;
|
|
1305
1294
|
remove(sync: SyncMode.Async): Promise<void>;
|
|
1306
1295
|
remove(sync: SyncMode): Promise<void> | void {
|
|
1307
|
-
|
|
1308
|
-
return new Promise(async (resolve, reject) => {
|
|
1309
|
-
try {
|
|
1310
|
-
await this[_daoConnection].remove();
|
|
1311
|
-
} catch (error) {
|
|
1312
|
-
reject(error);
|
|
1313
|
-
}
|
|
1314
|
-
});
|
|
1315
|
-
};
|
|
1296
|
+
|
|
1316
1297
|
}
|
|
1317
1298
|
|
|
1318
1299
|
restore(sync: SyncMode.Sync, name: string): void;
|
|
1319
1300
|
restore(sync: SyncMode.Async, name: string): Promise<void>;
|
|
1320
1301
|
restore(sync: SyncMode, name: string): Promise<void> | void {
|
|
1321
1302
|
if (sync === SyncMode.Async) {
|
|
1322
|
-
return
|
|
1323
|
-
try {
|
|
1324
|
-
await this[_daoConnection].restore(this[_sqliteRemoteName], name);
|
|
1325
|
-
} catch (error) {
|
|
1326
|
-
reject(error);
|
|
1327
|
-
}
|
|
1328
|
-
});
|
|
1303
|
+
return this[_daoDB]?.restore(this[_sqliteRemoteName], name);
|
|
1329
1304
|
};
|
|
1330
1305
|
}
|
|
1331
1306
|
}
|
|
@@ -3695,6 +3670,19 @@ export class SqlService<T extends object> {
|
|
|
3695
3670
|
}
|
|
3696
3671
|
}
|
|
3697
3672
|
|
|
3673
|
+
close(option?: MethodOption & { sync?: SyncMode.Async; }): Promise<void>;
|
|
3674
|
+
close(option: MethodOption & { sync: SyncMode.Sync; }): void;
|
|
3675
|
+
@P<T>()
|
|
3676
|
+
close(option?: MethodOption & { sync?: SyncMode; force?: boolean }): void | Promise<void> {
|
|
3677
|
+
const dbName = option?.dbName ?? this[_daoDBName] ?? _primaryDB;
|
|
3678
|
+
delete globalThis[_dao][this[_dbType]!][dbName];
|
|
3679
|
+
if (option?.sync === SyncMode.Async) {
|
|
3680
|
+
return option!.dao!.close(SyncMode.Async);
|
|
3681
|
+
} else if (option?.sync === SyncMode.Sync) {
|
|
3682
|
+
option!.dao!.close(SyncMode.Sync)
|
|
3683
|
+
}
|
|
3684
|
+
}
|
|
3685
|
+
|
|
3698
3686
|
/**
|
|
3699
3687
|
#创建表
|
|
3700
3688
|
** `tableName` 表名称
|