@capacitor-community/sqlite 3.5.1-1 → 3.5.1-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.
@@ -429,12 +429,7 @@ class UtilsSQLite {
429
429
  if (values != null && values.length > 0) {
430
430
  mVal = await this.replaceUndefinedByNull(values);
431
431
  }
432
- if (mVal.length > 0) {
433
- await db.run(sqlStmt, mVal);
434
- }
435
- else {
436
- await db.exec(sqlStmt);
437
- }
432
+ await this.runExec(db, sqlStmt, mVal);
438
433
  lastId = await this.getLastId(db);
439
434
  return Promise.resolve(lastId);
440
435
  }
@@ -442,6 +437,30 @@ class UtilsSQLite {
442
437
  return Promise.reject(`PrepareRun: ${err}`);
443
438
  }
444
439
  }
440
+ async runExec(db, stmt, values = []) {
441
+ return new Promise((resolve, reject) => {
442
+ if (values != null && values.length > 0) {
443
+ db.run(stmt, values, (err) => {
444
+ if (err) {
445
+ reject(err.message);
446
+ }
447
+ else {
448
+ resolve();
449
+ }
450
+ });
451
+ }
452
+ else {
453
+ db.exec(stmt, (err) => {
454
+ if (err) {
455
+ reject(err.message);
456
+ }
457
+ else {
458
+ resolve();
459
+ }
460
+ });
461
+ }
462
+ });
463
+ }
445
464
  /**
446
465
  * replaceUndefinedByNull
447
466
  * @param values