@capacitor-community/sqlite 4.1.0-4 → 4.1.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.
- package/README.md +8 -5
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java +160 -92
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +41 -21
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +92 -107
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsUpgrade.java +36 -319
- package/dist/esm/definitions.d.ts +32 -15
- package/dist/esm/definitions.js +191 -105
- package/dist/esm/definitions.js.map +1 -1
- package/dist/plugin.cjs.js +191 -105
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +191 -105
- package/dist/plugin.js.map +1 -1
- package/electron/dist/plugin.js +47 -332
- package/electron/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorSQLite.swift +123 -59
- package/ios/Plugin/CapacitorSQLitePlugin.swift +53 -20
- package/ios/Plugin/Database.swift +15 -11
- package/ios/Plugin/Utils/UtilsUpgrade.swift +36 -369
- package/package.json +2 -2
package/dist/plugin.cjs.js
CHANGED
|
@@ -79,12 +79,10 @@ class SQLiteConnection {
|
|
|
79
79
|
return Promise.reject(err);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
async addUpgradeStatement(database,
|
|
82
|
+
async addUpgradeStatement(database, toVersion, statements) {
|
|
83
83
|
const upgrade = {
|
|
84
|
-
fromVersion,
|
|
85
84
|
toVersion,
|
|
86
|
-
|
|
87
|
-
set: set ? set : [],
|
|
85
|
+
statements,
|
|
88
86
|
};
|
|
89
87
|
try {
|
|
90
88
|
if (database.endsWith('.db'))
|
|
@@ -99,7 +97,7 @@ class SQLiteConnection {
|
|
|
99
97
|
return Promise.reject(err);
|
|
100
98
|
}
|
|
101
99
|
}
|
|
102
|
-
async createConnection(database, encrypted, mode, version) {
|
|
100
|
+
async createConnection(database, encrypted, mode, version, readonly) {
|
|
103
101
|
try {
|
|
104
102
|
if (database.endsWith('.db'))
|
|
105
103
|
database = database.slice(0, -3);
|
|
@@ -108,39 +106,44 @@ class SQLiteConnection {
|
|
|
108
106
|
encrypted,
|
|
109
107
|
mode,
|
|
110
108
|
version,
|
|
109
|
+
readonly,
|
|
111
110
|
});
|
|
112
|
-
const conn = new SQLiteDBConnection(database, this.sqlite);
|
|
113
|
-
|
|
111
|
+
const conn = new SQLiteDBConnection(database, readonly, this.sqlite);
|
|
112
|
+
const connName = readonly ? `RO_${database}` : `RW_${database}`;
|
|
113
|
+
this._connectionDict.set(connName, conn);
|
|
114
114
|
return Promise.resolve(conn);
|
|
115
115
|
}
|
|
116
116
|
catch (err) {
|
|
117
117
|
return Promise.reject(err);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
async closeConnection(database) {
|
|
120
|
+
async closeConnection(database, readonly) {
|
|
121
121
|
try {
|
|
122
122
|
if (database.endsWith('.db'))
|
|
123
123
|
database = database.slice(0, -3);
|
|
124
|
-
await this.sqlite.closeConnection({ database });
|
|
125
|
-
|
|
124
|
+
await this.sqlite.closeConnection({ database, readonly });
|
|
125
|
+
const connName = readonly ? `RO_${database}` : `RW_${database}`;
|
|
126
|
+
this._connectionDict.delete(connName);
|
|
126
127
|
return Promise.resolve();
|
|
127
128
|
}
|
|
128
129
|
catch (err) {
|
|
129
130
|
return Promise.reject(err);
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
|
-
async isConnection(database) {
|
|
133
|
+
async isConnection(database, readonly) {
|
|
133
134
|
const res = {};
|
|
134
135
|
if (database.endsWith('.db'))
|
|
135
136
|
database = database.slice(0, -3);
|
|
136
|
-
|
|
137
|
+
const connName = readonly ? `RO_${database}` : `RW_${database}`;
|
|
138
|
+
res.result = this._connectionDict.has(connName);
|
|
137
139
|
return Promise.resolve(res);
|
|
138
140
|
}
|
|
139
|
-
async retrieveConnection(database) {
|
|
141
|
+
async retrieveConnection(database, readonly) {
|
|
140
142
|
if (database.endsWith('.db'))
|
|
141
143
|
database = database.slice(0, -3);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
const connName = readonly ? `RO_${database}` : `RW_${database}`;
|
|
145
|
+
if (this._connectionDict.has(connName)) {
|
|
146
|
+
const conn = this._connectionDict.get(connName);
|
|
144
147
|
if (typeof conn != 'undefined')
|
|
145
148
|
return Promise.resolve(conn);
|
|
146
149
|
else {
|
|
@@ -169,8 +172,9 @@ class SQLiteConnection {
|
|
|
169
172
|
databasePath,
|
|
170
173
|
version,
|
|
171
174
|
});
|
|
172
|
-
const conn = new SQLiteDBConnection(databasePath, this.sqlite);
|
|
173
|
-
|
|
175
|
+
const conn = new SQLiteDBConnection(databasePath, true, this.sqlite);
|
|
176
|
+
const connName = `RO_${databasePath})`;
|
|
177
|
+
this._connectionDict.set(connName, conn);
|
|
174
178
|
return Promise.resolve(conn);
|
|
175
179
|
}
|
|
176
180
|
catch (err) {
|
|
@@ -180,7 +184,8 @@ class SQLiteConnection {
|
|
|
180
184
|
async closeNCConnection(databasePath) {
|
|
181
185
|
try {
|
|
182
186
|
await this.sqlite.closeNCConnection({ databasePath });
|
|
183
|
-
|
|
187
|
+
const connName = `RO_${databasePath})`;
|
|
188
|
+
this._connectionDict.delete(connName);
|
|
184
189
|
return Promise.resolve();
|
|
185
190
|
}
|
|
186
191
|
catch (err) {
|
|
@@ -189,12 +194,14 @@ class SQLiteConnection {
|
|
|
189
194
|
}
|
|
190
195
|
async isNCConnection(databasePath) {
|
|
191
196
|
const res = {};
|
|
192
|
-
|
|
197
|
+
const connName = `RO_${databasePath})`;
|
|
198
|
+
res.result = this._connectionDict.has(connName);
|
|
193
199
|
return Promise.resolve(res);
|
|
194
200
|
}
|
|
195
201
|
async retrieveNCConnection(databasePath) {
|
|
196
202
|
if (this._connectionDict.has(databasePath)) {
|
|
197
|
-
const
|
|
203
|
+
const connName = `RO_${databasePath})`;
|
|
204
|
+
const conn = this._connectionDict.get(connName);
|
|
198
205
|
if (typeof conn != 'undefined')
|
|
199
206
|
return Promise.resolve(conn);
|
|
200
207
|
else {
|
|
@@ -220,12 +227,14 @@ class SQLiteConnection {
|
|
|
220
227
|
async closeAllConnections() {
|
|
221
228
|
const delDict = new Map();
|
|
222
229
|
try {
|
|
223
|
-
for (const
|
|
224
|
-
|
|
225
|
-
|
|
230
|
+
for (const key of this._connectionDict.keys()) {
|
|
231
|
+
const database = key.substring(3);
|
|
232
|
+
const readonly = key.substring(0, 3) === ("RO_") ? true : false;
|
|
233
|
+
await this.sqlite.closeConnection({ database, readonly });
|
|
234
|
+
delDict.set(key, null);
|
|
226
235
|
}
|
|
227
|
-
for (const
|
|
228
|
-
this._connectionDict.delete(
|
|
236
|
+
for (const key of delDict.keys()) {
|
|
237
|
+
this._connectionDict.delete(key);
|
|
229
238
|
}
|
|
230
239
|
return Promise.resolve();
|
|
231
240
|
}
|
|
@@ -349,16 +358,23 @@ class SQLiteConnection {
|
|
|
349
358
|
* SQLiteDBConnection Class
|
|
350
359
|
*/
|
|
351
360
|
class SQLiteDBConnection {
|
|
352
|
-
constructor(dbName, sqlite) {
|
|
361
|
+
constructor(dbName, readonly, sqlite) {
|
|
353
362
|
this.dbName = dbName;
|
|
363
|
+
this.readonly = readonly;
|
|
354
364
|
this.sqlite = sqlite;
|
|
355
365
|
}
|
|
356
366
|
getConnectionDBName() {
|
|
357
367
|
return this.dbName;
|
|
358
368
|
}
|
|
369
|
+
getConnectionReadOnly() {
|
|
370
|
+
return this.readonly;
|
|
371
|
+
}
|
|
359
372
|
async open() {
|
|
360
373
|
try {
|
|
361
|
-
await this.sqlite.open({
|
|
374
|
+
await this.sqlite.open({
|
|
375
|
+
database: this.dbName,
|
|
376
|
+
readonly: this.readonly,
|
|
377
|
+
});
|
|
362
378
|
return Promise.resolve();
|
|
363
379
|
}
|
|
364
380
|
catch (err) {
|
|
@@ -367,7 +383,10 @@ class SQLiteDBConnection {
|
|
|
367
383
|
}
|
|
368
384
|
async close() {
|
|
369
385
|
try {
|
|
370
|
-
await this.sqlite.close({
|
|
386
|
+
await this.sqlite.close({
|
|
387
|
+
database: this.dbName,
|
|
388
|
+
readonly: this.readonly,
|
|
389
|
+
});
|
|
371
390
|
return Promise.resolve();
|
|
372
391
|
}
|
|
373
392
|
catch (err) {
|
|
@@ -378,6 +397,7 @@ class SQLiteDBConnection {
|
|
|
378
397
|
try {
|
|
379
398
|
const res = await this.sqlite.getUrl({
|
|
380
399
|
database: this.dbName,
|
|
400
|
+
readonly: this.readonly,
|
|
381
401
|
});
|
|
382
402
|
return Promise.resolve(res);
|
|
383
403
|
}
|
|
@@ -389,6 +409,7 @@ class SQLiteDBConnection {
|
|
|
389
409
|
try {
|
|
390
410
|
const version = await this.sqlite.getVersion({
|
|
391
411
|
database: this.dbName,
|
|
412
|
+
readonly: this.readonly,
|
|
392
413
|
});
|
|
393
414
|
return Promise.resolve(version);
|
|
394
415
|
}
|
|
@@ -400,6 +421,7 @@ class SQLiteDBConnection {
|
|
|
400
421
|
try {
|
|
401
422
|
const res = await this.sqlite.getTableList({
|
|
402
423
|
database: this.dbName,
|
|
424
|
+
readonly: this.readonly,
|
|
403
425
|
});
|
|
404
426
|
return Promise.resolve(res);
|
|
405
427
|
}
|
|
@@ -409,12 +431,18 @@ class SQLiteDBConnection {
|
|
|
409
431
|
}
|
|
410
432
|
async execute(statements, transaction = true) {
|
|
411
433
|
try {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
434
|
+
if (!this.readonly) {
|
|
435
|
+
const res = await this.sqlite.execute({
|
|
436
|
+
database: this.dbName,
|
|
437
|
+
statements: statements,
|
|
438
|
+
transaction: transaction,
|
|
439
|
+
readonly: false,
|
|
440
|
+
});
|
|
441
|
+
return Promise.resolve(res);
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
return Promise.reject('not allowed in read-only mode');
|
|
445
|
+
}
|
|
418
446
|
}
|
|
419
447
|
catch (err) {
|
|
420
448
|
return Promise.reject(err);
|
|
@@ -428,6 +456,7 @@ class SQLiteDBConnection {
|
|
|
428
456
|
database: this.dbName,
|
|
429
457
|
statement: statement,
|
|
430
458
|
values: values,
|
|
459
|
+
readonly: this.readonly,
|
|
431
460
|
});
|
|
432
461
|
}
|
|
433
462
|
else {
|
|
@@ -435,6 +464,7 @@ class SQLiteDBConnection {
|
|
|
435
464
|
database: this.dbName,
|
|
436
465
|
statement: statement,
|
|
437
466
|
values: [],
|
|
467
|
+
readonly: this.readonly,
|
|
438
468
|
});
|
|
439
469
|
}
|
|
440
470
|
if (res && typeof res.values[0] === 'object') {
|
|
@@ -462,24 +492,31 @@ class SQLiteDBConnection {
|
|
|
462
492
|
async run(statement, values, transaction = true) {
|
|
463
493
|
let res;
|
|
464
494
|
try {
|
|
465
|
-
if (
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
495
|
+
if (!this.readonly) {
|
|
496
|
+
if (values && values.length > 0) {
|
|
497
|
+
res = await this.sqlite.run({
|
|
498
|
+
database: this.dbName,
|
|
499
|
+
statement: statement,
|
|
500
|
+
values: values,
|
|
501
|
+
transaction: transaction,
|
|
502
|
+
readonly: false,
|
|
503
|
+
});
|
|
504
|
+
// }
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
res = await this.sqlite.run({
|
|
508
|
+
database: this.dbName,
|
|
509
|
+
statement: statement,
|
|
510
|
+
values: [],
|
|
511
|
+
transaction: transaction,
|
|
512
|
+
readonly: false,
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
return Promise.resolve(res);
|
|
473
516
|
}
|
|
474
517
|
else {
|
|
475
|
-
|
|
476
|
-
database: this.dbName,
|
|
477
|
-
statement: statement,
|
|
478
|
-
values: [],
|
|
479
|
-
transaction: transaction,
|
|
480
|
-
});
|
|
518
|
+
return Promise.reject('not allowed in read-only mode');
|
|
481
519
|
}
|
|
482
|
-
return Promise.resolve(res);
|
|
483
520
|
}
|
|
484
521
|
catch (err) {
|
|
485
522
|
return Promise.reject(err);
|
|
@@ -487,13 +524,19 @@ class SQLiteDBConnection {
|
|
|
487
524
|
}
|
|
488
525
|
async executeSet(set, transaction = true) {
|
|
489
526
|
try {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
527
|
+
if (!this.readonly) {
|
|
528
|
+
const res = await this.sqlite.executeSet({
|
|
529
|
+
database: this.dbName,
|
|
530
|
+
set: set,
|
|
531
|
+
transaction: transaction,
|
|
532
|
+
readonly: false,
|
|
533
|
+
});
|
|
534
|
+
// }
|
|
535
|
+
return Promise.resolve(res);
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
return Promise.reject('not allowed in read-only mode');
|
|
539
|
+
}
|
|
497
540
|
}
|
|
498
541
|
catch (err) {
|
|
499
542
|
return Promise.reject(err);
|
|
@@ -503,6 +546,7 @@ class SQLiteDBConnection {
|
|
|
503
546
|
try {
|
|
504
547
|
const res = await this.sqlite.isDBExists({
|
|
505
548
|
database: this.dbName,
|
|
549
|
+
readonly: this.readonly,
|
|
506
550
|
});
|
|
507
551
|
return Promise.resolve(res);
|
|
508
552
|
}
|
|
@@ -515,6 +559,7 @@ class SQLiteDBConnection {
|
|
|
515
559
|
const res = await this.sqlite.isTableExists({
|
|
516
560
|
database: this.dbName,
|
|
517
561
|
table: table,
|
|
562
|
+
readonly: this.readonly,
|
|
518
563
|
});
|
|
519
564
|
return Promise.resolve(res);
|
|
520
565
|
}
|
|
@@ -526,6 +571,7 @@ class SQLiteDBConnection {
|
|
|
526
571
|
try {
|
|
527
572
|
const res = await this.sqlite.isDBOpen({
|
|
528
573
|
database: this.dbName,
|
|
574
|
+
readonly: this.readonly,
|
|
529
575
|
});
|
|
530
576
|
return Promise.resolve(res);
|
|
531
577
|
}
|
|
@@ -535,8 +581,16 @@ class SQLiteDBConnection {
|
|
|
535
581
|
}
|
|
536
582
|
async delete() {
|
|
537
583
|
try {
|
|
538
|
-
|
|
539
|
-
|
|
584
|
+
if (!this.readonly) {
|
|
585
|
+
await this.sqlite.deleteDatabase({
|
|
586
|
+
database: this.dbName,
|
|
587
|
+
readonly: false,
|
|
588
|
+
});
|
|
589
|
+
return Promise.resolve();
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
return Promise.reject('not allowed in read-only mode');
|
|
593
|
+
}
|
|
540
594
|
}
|
|
541
595
|
catch (err) {
|
|
542
596
|
return Promise.reject(err);
|
|
@@ -544,10 +598,16 @@ class SQLiteDBConnection {
|
|
|
544
598
|
}
|
|
545
599
|
async createSyncTable() {
|
|
546
600
|
try {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
601
|
+
if (!this.readonly) {
|
|
602
|
+
const res = await this.sqlite.createSyncTable({
|
|
603
|
+
database: this.dbName,
|
|
604
|
+
readonly: false,
|
|
605
|
+
});
|
|
606
|
+
return Promise.resolve(res);
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
return Promise.reject('not allowed in read-only mode');
|
|
610
|
+
}
|
|
551
611
|
}
|
|
552
612
|
catch (err) {
|
|
553
613
|
return Promise.reject(err);
|
|
@@ -555,11 +615,17 @@ class SQLiteDBConnection {
|
|
|
555
615
|
}
|
|
556
616
|
async setSyncDate(syncdate) {
|
|
557
617
|
try {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
618
|
+
if (!this.readonly) {
|
|
619
|
+
await this.sqlite.setSyncDate({
|
|
620
|
+
database: this.dbName,
|
|
621
|
+
syncdate: syncdate,
|
|
622
|
+
readonly: false,
|
|
623
|
+
});
|
|
624
|
+
return Promise.resolve();
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
return Promise.reject('not allowed in read-only mode');
|
|
628
|
+
}
|
|
563
629
|
}
|
|
564
630
|
catch (err) {
|
|
565
631
|
return Promise.reject(err);
|
|
@@ -569,6 +635,7 @@ class SQLiteDBConnection {
|
|
|
569
635
|
try {
|
|
570
636
|
const res = await this.sqlite.getSyncDate({
|
|
571
637
|
database: this.dbName,
|
|
638
|
+
readonly: this.readonly,
|
|
572
639
|
});
|
|
573
640
|
let retDate = '';
|
|
574
641
|
if (res.syncDate > 0)
|
|
@@ -584,6 +651,7 @@ class SQLiteDBConnection {
|
|
|
584
651
|
const res = await this.sqlite.exportToJson({
|
|
585
652
|
database: this.dbName,
|
|
586
653
|
jsonexportmode: mode,
|
|
654
|
+
readonly: this.readonly,
|
|
587
655
|
});
|
|
588
656
|
return Promise.resolve(res);
|
|
589
657
|
}
|
|
@@ -593,8 +661,16 @@ class SQLiteDBConnection {
|
|
|
593
661
|
}
|
|
594
662
|
async deleteExportedRows() {
|
|
595
663
|
try {
|
|
596
|
-
|
|
597
|
-
|
|
664
|
+
if (!this.readonly) {
|
|
665
|
+
await this.sqlite.deleteExportedRows({
|
|
666
|
+
database: this.dbName,
|
|
667
|
+
readonly: false,
|
|
668
|
+
});
|
|
669
|
+
return Promise.resolve();
|
|
670
|
+
}
|
|
671
|
+
else {
|
|
672
|
+
return Promise.reject('not allowed in read-only mode');
|
|
673
|
+
}
|
|
598
674
|
}
|
|
599
675
|
catch (err) {
|
|
600
676
|
return Promise.reject(err);
|
|
@@ -602,55 +678,65 @@ class SQLiteDBConnection {
|
|
|
602
678
|
}
|
|
603
679
|
async executeTransaction(txn) {
|
|
604
680
|
try {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
for (const task of txn) {
|
|
614
|
-
if (task.values && task.values.length > 0) {
|
|
615
|
-
const ret = await this.sqlite.run({
|
|
616
|
-
database: this.dbName,
|
|
617
|
-
statement: task.statement,
|
|
618
|
-
values: task.values,
|
|
619
|
-
transaction: false,
|
|
620
|
-
});
|
|
621
|
-
if (ret.changes.lastId === -1) {
|
|
622
|
-
await this.execute('ROLLBACK;', false);
|
|
623
|
-
return Promise.reject('Error in transaction run ');
|
|
624
|
-
}
|
|
681
|
+
if (!this.readonly) {
|
|
682
|
+
const ret = await this.sqlite.execute({
|
|
683
|
+
database: this.dbName,
|
|
684
|
+
statements: 'BEGIN TRANSACTION;',
|
|
685
|
+
transaction: false,
|
|
686
|
+
});
|
|
687
|
+
if (ret.changes.changes < 0) {
|
|
688
|
+
return Promise.reject('Error in BEGIN TRANSACTION');
|
|
625
689
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
690
|
+
for (const task of txn) {
|
|
691
|
+
if (task.values && task.values.length > 0) {
|
|
692
|
+
const ret = await this.sqlite.run({
|
|
693
|
+
database: this.dbName,
|
|
694
|
+
statement: task.statement,
|
|
695
|
+
values: task.values,
|
|
696
|
+
transaction: false,
|
|
697
|
+
readonly: false,
|
|
698
|
+
});
|
|
699
|
+
if (ret.changes.lastId === -1) {
|
|
700
|
+
await this.execute('ROLLBACK;', false);
|
|
701
|
+
return Promise.reject('Error in transaction run ');
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
else {
|
|
705
|
+
const ret = await this.sqlite.execute({
|
|
634
706
|
database: this.dbName,
|
|
635
|
-
statements:
|
|
707
|
+
statements: task.statement,
|
|
636
708
|
transaction: false,
|
|
709
|
+
readonly: false,
|
|
637
710
|
});
|
|
638
|
-
|
|
711
|
+
if (ret.changes.changes < 0) {
|
|
712
|
+
await this.sqlite.execute({
|
|
713
|
+
database: this.dbName,
|
|
714
|
+
statements: 'ROLLBACK;',
|
|
715
|
+
transaction: false,
|
|
716
|
+
readonly: false,
|
|
717
|
+
});
|
|
718
|
+
return Promise.reject('Error in transaction execute ');
|
|
719
|
+
}
|
|
639
720
|
}
|
|
640
721
|
}
|
|
722
|
+
await this.sqlite.execute({
|
|
723
|
+
database: this.dbName,
|
|
724
|
+
statements: 'COMMIT;',
|
|
725
|
+
transaction: false,
|
|
726
|
+
readonly: false,
|
|
727
|
+
});
|
|
728
|
+
return Promise.resolve();
|
|
729
|
+
}
|
|
730
|
+
else {
|
|
731
|
+
return Promise.reject('not allowed in read-only mode');
|
|
641
732
|
}
|
|
642
|
-
await this.sqlite.execute({
|
|
643
|
-
database: this.dbName,
|
|
644
|
-
statements: 'COMMIT;',
|
|
645
|
-
transaction: false,
|
|
646
|
-
});
|
|
647
|
-
return Promise.resolve();
|
|
648
733
|
}
|
|
649
734
|
catch (err) {
|
|
650
735
|
await this.sqlite.execute({
|
|
651
736
|
database: this.dbName,
|
|
652
737
|
statements: 'ROLLBACK;',
|
|
653
738
|
transaction: false,
|
|
739
|
+
readonly: false,
|
|
654
740
|
});
|
|
655
741
|
return Promise.reject(err);
|
|
656
742
|
}
|