@capacitor-community/sqlite 4.1.0-8 → 4.1.0

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.
@@ -482,30 +482,38 @@ enum CapacitorSQLiteError: Error {
482
482
 
483
483
  // MARK: - CheckConnectionsConsistency
484
484
 
485
- @objc public func checkConnectionsConsistency(_ dbNames: [String]) throws -> NSNumber {
485
+ @objc public func checkConnectionsConsistency(_ dbNames: [String],
486
+ openModes: [String])
487
+ throws -> NSNumber {
486
488
  if isInit {
487
489
  var keys: [String] = Array(self.dbDict.keys)
490
+ var idx: Int = 0
491
+ var conns: [String] = []
492
+ for name in dbNames {
493
+ conns.append("\(openModes[idx])_\(name)")
494
+ idx = idx + 1
495
+ }
488
496
  do {
489
- if dbNames.count == 0 {
497
+ if conns.count == 0 {
490
498
  try closeAllConnections()
491
499
  return 0
492
500
  }
493
- if keys.count < dbNames.count {
501
+ if keys.count < conns.count {
494
502
  // not solvable inconsistency
495
503
  try closeAllConnections()
496
504
  return 0
497
505
  }
498
- if keys.count > dbNames.count {
506
+ if keys.count > conns.count {
499
507
  for key in keys {
500
- if !dbNames.contains(key) {
508
+ if !conns.contains(key) {
501
509
  self.dbDict.removeValue(forKey: key)
502
510
  }
503
511
  }
504
512
  }
505
513
  keys = Array(self.dbDict.keys)
506
- if keys.count == dbNames.count {
514
+ if keys.count == conns.count {
507
515
  let set1 = Set(keys)
508
- let set2 = Set(dbNames)
516
+ let set2 = Set(conns)
509
517
  let arr = Array(set1.symmetricDifference(set2))
510
518
  if arr.count == 0 {
511
519
  return 1
@@ -794,7 +802,7 @@ enum CapacitorSQLiteError: Error {
794
802
 
795
803
  // MARK: - isDBOpen
796
804
 
797
- @objc func isDBOpen(_ dbName: String, readonly: Bool) throws -> NSNumber {
805
+ @objc func isDBOpen(_ dbName: String, readonly: Bool) throws -> NSNumber {
798
806
  if isInit {
799
807
  let mDbName = CapacitorSQLite.getDatabaseName(dbName: dbName)
800
808
  let connName: String = readonly ? "RO_\(mDbName)" : "RW_\(mDbName)"
@@ -346,8 +346,17 @@ public class CapacitorSQLitePlugin: CAPPlugin {
346
346
  "Connection Array")
347
347
  return
348
348
  }
349
+ guard let openModes = call.options["openModes"] as? [String] else {
350
+ retHandler.rResult(
351
+ call: call,
352
+ message: "CheckConnectionsConsistency: Must provide a " +
353
+ "OpenModes Array")
354
+ return
355
+ }
349
356
  do {
350
- let res = try implementation?.checkConnectionsConsistency(dbNames)
357
+ let res = try implementation?
358
+ .checkConnectionsConsistency(dbNames,
359
+ openModes: openModes)
351
360
  var bRes: Bool = false
352
361
  if res == 1 {
353
362
  bRes = true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/sqlite",
3
- "version": "4.1.0-8",
3
+ "version": "4.1.0",
4
4
  "description": "Community plugin for native & electron SQLite databases",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -93,6 +93,6 @@
93
93
  }
94
94
  },
95
95
  "dependencies": {
96
- "jeep-sqlite": "^1.5.8"
96
+ "jeep-sqlite": "^1.6.2"
97
97
  }
98
98
  }