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