@capacitor-community/sqlite 3.2.5 → 3.3.3-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.
Files changed (38) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/README.md +36 -2
  3. package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java +86 -10
  4. package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +101 -3
  5. package/android/src/main/java/com/getcapacitor/community/database/sqlite/RetHandler.java +24 -0
  6. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +67 -47
  7. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/JsonIndex.java +5 -4
  8. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsFile.java +9 -0
  9. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsMigrate.java +34 -15
  10. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsNCDatabase.java +26 -0
  11. package/dist/esm/definitions.d.ts +111 -2
  12. package/dist/esm/definitions.js +63 -0
  13. package/dist/esm/definitions.js.map +1 -1
  14. package/dist/esm/web.d.ts +5 -1
  15. package/dist/esm/web.js +16 -0
  16. package/dist/esm/web.js.map +1 -1
  17. package/dist/plugin.cjs.js +79 -0
  18. package/dist/plugin.cjs.js.map +1 -1
  19. package/dist/plugin.js +79 -0
  20. package/dist/plugin.js.map +1 -1
  21. package/electron/dist/plugin.js +17 -1
  22. package/electron/dist/plugin.js.map +1 -1
  23. package/ios/Plugin/CapacitorSQLite.swift +122 -19
  24. package/ios/Plugin/CapacitorSQLitePlugin.m +4 -0
  25. package/ios/Plugin/CapacitorSQLitePlugin.swift +236 -64
  26. package/ios/Plugin/Database.swift +57 -28
  27. package/ios/Plugin/ImportExportJson/ImportFromJson.swift +2 -1
  28. package/ios/Plugin/ImportExportJson/JsonSQLite.swift +1 -1
  29. package/ios/Plugin/ReturnHandler.swift +13 -0
  30. package/ios/Plugin/SqliteConfig.swift +10 -0
  31. package/ios/Plugin/Utils/UtilsEncryption.swift +10 -7
  32. package/ios/Plugin/Utils/UtilsFile.swift +207 -38
  33. package/ios/Plugin/Utils/UtilsMigrate.swift +70 -57
  34. package/ios/Plugin/Utils/UtilsNCDatabase.swift +31 -0
  35. package/ios/Plugin/Utils/UtilsSQLCipher.swift +29 -24
  36. package/ios/Plugin/Utils/UtilsSecret.swift +22 -8
  37. package/ios/Plugin/Utils/UtilsUpgrade.swift +6 -2
  38. package/package.json +5 -5
@@ -5,7 +5,7 @@ import Capacitor
5
5
  // swiftlint:disable file_length
6
6
  // swiftlint:disable type_body_length
7
7
  public class CapacitorSQLitePlugin: CAPPlugin {
8
- private let implementation = CapacitorSQLite()
8
+ private var implementation: CapacitorSQLite?
9
9
  private let modeList: [String] = ["no-encryption", "encryption", "secret", "newsecret", "wrongsecret"]
10
10
  private let retHandler: ReturnHandler = ReturnHandler()
11
11
  private var versionUpgrades: [String: [Int: [String: Any]]] = [:]
@@ -13,6 +13,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
13
13
  var exportObserver: Any?
14
14
 
15
15
  override public func load() {
16
+ self.implementation = CapacitorSQLite(config: sqliteConfig())
16
17
  self.addObserversToNotificationCenter()
17
18
  }
18
19
  deinit {
@@ -24,16 +25,18 @@ public class CapacitorSQLitePlugin: CAPPlugin {
24
25
 
25
26
  @objc func echo(_ call: CAPPluginCall) {
26
27
  let value = call.getString("value") ?? ""
27
- call.resolve([
28
- "value": implementation.echo(value)
29
- ])
28
+ if let retValue: String = implementation?.echo(value) {
29
+ call.resolve([
30
+ "value": retValue
31
+ ])
32
+ }
30
33
  }
31
34
 
32
35
  // MARK: - IsSecretStored
33
36
 
34
37
  @objc func isSecretStored(_ call: CAPPluginCall) {
35
38
  do {
36
- let res = try implementation.isSecretStored()
39
+ let res = try implementation?.isSecretStored()
37
40
  var bRes: Bool = false
38
41
  if res == 1 {
39
42
  bRes = true
@@ -64,7 +67,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
64
67
  return
65
68
  }
66
69
  do {
67
- try implementation.setEncryptionSecret(passphrase: passphrase)
70
+ try implementation?.setEncryptionSecret(passphrase: passphrase)
68
71
  retHandler.rResult(call: call)
69
72
  return
70
73
  } catch CapacitorSQLiteError.failed(let message) {
@@ -96,7 +99,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
96
99
  return
97
100
  }
98
101
  do {
99
- try implementation.changeEncryptionSecret(passphrase: passphrase, oldPassphrase: oldPassphrase)
102
+ try implementation?.changeEncryptionSecret(passphrase: passphrase, oldPassphrase: oldPassphrase)
100
103
  retHandler.rResult(call: call)
101
104
  return
102
105
  } catch CapacitorSQLiteError.failed(let message) {
@@ -135,11 +138,11 @@ public class CapacitorSQLitePlugin: CAPPlugin {
135
138
  upgDict = cUpgDict
136
139
  }
137
140
  do {
138
- try implementation.createConnection(dbName,
139
- encrypted: encrypted,
140
- mode: inMode,
141
- version: version,
142
- vUpgDict: upgDict)
141
+ try implementation?.createConnection(dbName,
142
+ encrypted: encrypted,
143
+ mode: inMode,
144
+ version: version,
145
+ vUpgDict: upgDict)
143
146
  retHandler.rResult(call: call)
144
147
  return
145
148
  } catch CapacitorSQLiteError.failed(let message) {
@@ -164,7 +167,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
164
167
  return
165
168
  }
166
169
  do {
167
- try implementation.open(dbName)
170
+ try implementation?.open(dbName)
168
171
  retHandler.rResult(call: call)
169
172
  return
170
173
  } catch CapacitorSQLiteError.failed(let message) {
@@ -189,7 +192,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
189
192
  return
190
193
  }
191
194
  do {
192
- try implementation.close(dbName)
195
+ try implementation?.close(dbName)
193
196
  retHandler.rResult(call: call)
194
197
  return
195
198
  } catch CapacitorSQLiteError.failed(let message) {
@@ -214,9 +217,15 @@ public class CapacitorSQLitePlugin: CAPPlugin {
214
217
  return
215
218
  }
216
219
  do {
217
- let version: NSNumber = try implementation.getVersion(dbName)
218
- retHandler.rVersion(call: call, ret: version)
219
- return
220
+ if let version: NSNumber = try implementation?
221
+ .getVersion(dbName) {
222
+ retHandler.rVersion(call: call, ret: version)
223
+ return
224
+ } else {
225
+ let msg = "GetVersion: Does not return a valid version"
226
+ retHandler.rVersion(call: call, message: msg)
227
+ return
228
+ }
220
229
  } catch CapacitorSQLiteError.failed(let message) {
221
230
  let msg = "GetVersion: \(message)"
222
231
  retHandler.rVersion(call: call, message: msg)
@@ -239,7 +248,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
239
248
  return
240
249
  }
241
250
  do {
242
- try implementation.closeConnection(dbName)
251
+ try implementation?.closeConnection(dbName)
243
252
  retHandler.rResult(call: call)
244
253
  return
245
254
  } catch CapacitorSQLiteError.failed(let message) {
@@ -266,7 +275,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
266
275
  return
267
276
  }
268
277
  do {
269
- let res = try implementation.checkConnectionsConsistency(dbNames)
278
+ let res = try implementation?.checkConnectionsConsistency(dbNames)
270
279
  var bRes: Bool = false
271
280
  if res == 1 {
272
281
  bRes = true
@@ -291,7 +300,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
291
300
  return
292
301
  }
293
302
  do {
294
- let res = try implementation.isDatabase(dbName)
303
+ let res = try implementation?.isDatabase(dbName)
295
304
  var bRes: Bool = false
296
305
  if res == 1 {
297
306
  bRes = true
@@ -326,7 +335,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
326
335
  return
327
336
  }
328
337
  do {
329
- let res = try implementation.isTableExists(dbName, tableName: tableName)
338
+ let res = try implementation?.isTableExists(dbName, tableName: tableName)
330
339
  var bRes: Bool = false
331
340
  if res == 1 {
332
341
  bRes = true
@@ -349,7 +358,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
349
358
  @objc func getDatabaseList(_ call: CAPPluginCall) {
350
359
 
351
360
  do {
352
- let res = try implementation.getDatabaseList()
361
+ let res = try implementation?.getDatabaseList() ?? []
353
362
  retHandler.rValues(call: call, ret: res)
354
363
  return
355
364
  } catch CapacitorSQLiteError.failed(let message) {
@@ -376,7 +385,8 @@ public class CapacitorSQLitePlugin: CAPPlugin {
376
385
  }
377
386
 
378
387
  do {
379
- let res = try implementation.getMigratableDbList(dbFolder)
388
+ let res = try implementation?
389
+ .getMigratableDbList(dbFolder) ?? []
380
390
  retHandler.rValues(call: call, ret: res)
381
391
  return
382
392
  } catch CapacitorSQLiteError.failed(let message) {
@@ -406,7 +416,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
406
416
  }
407
417
  }
408
418
  do {
409
- try implementation.addSQLiteSuffix(folderPath, dbList: dbList)
419
+ try implementation?.addSQLiteSuffix(folderPath, dbList: dbList)
410
420
  retHandler.rResult(call: call)
411
421
  return
412
422
  } catch CapacitorSQLiteError.failed(let message) {
@@ -435,7 +445,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
435
445
  }
436
446
  }
437
447
  do {
438
- try implementation.deleteOldDatabases(folderPath, dbList: dbList)
448
+ try implementation?.deleteOldDatabases(folderPath, dbList: dbList)
439
449
  retHandler.rResult(call: call)
440
450
  return
441
451
  } catch CapacitorSQLiteError.failed(let message) {
@@ -470,10 +480,17 @@ public class CapacitorSQLitePlugin: CAPPlugin {
470
480
  return
471
481
  }
472
482
  do {
473
- let res = try implementation.execute(dbName, statements: statements,
474
- transaction: transaction)
475
- retHandler.rChanges(call: call, ret: res)
476
- return
483
+ if let res = try implementation?
484
+ .execute(dbName, statements: statements,
485
+ transaction: transaction) {
486
+ retHandler.rChanges(call: call, ret: res)
487
+ return
488
+ } else {
489
+ retHandler.rChanges(
490
+ call: call, ret: ["changes": -1],
491
+ message: "Execute: Does not return a valid execute")
492
+ return
493
+ }
477
494
  } catch CapacitorSQLiteError.failed(let message) {
478
495
  retHandler.rChanges(
479
496
  call: call, ret: ["changes": -1],
@@ -526,10 +543,17 @@ public class CapacitorSQLitePlugin: CAPPlugin {
526
543
  }
527
544
  let transaction: Bool = call.getBool("transaction") ?? true
528
545
  do {
529
- let res = try implementation.executeSet(dbName, set: set,
530
- transaction: transaction)
531
- retHandler.rChanges(call: call, ret: res)
532
- return
546
+ if let res = try implementation?.executeSet(dbName, set: set,
547
+ transaction: transaction) {
548
+ retHandler.rChanges(call: call, ret: res)
549
+ return
550
+ } else {
551
+ retHandler.rChanges(
552
+ call: call, ret: ["changes": -1],
553
+ message: "ExecuteSet: Does not return a valid executeSet")
554
+ return
555
+
556
+ }
533
557
  } catch CapacitorSQLiteError.failed(let message) {
534
558
  retHandler.rChanges(
535
559
  call: call, ret: ["changes": -1],
@@ -547,6 +571,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
547
571
 
548
572
  // MARK: - Run
549
573
 
574
+ // swiftlint:disable function_body_length
550
575
  @objc func run(_ call: CAPPluginCall) {
551
576
  guard let dbName = call.options["database"] as? String else {
552
577
  retHandler.rChanges(
@@ -572,13 +597,19 @@ public class CapacitorSQLitePlugin: CAPPlugin {
572
597
  }
573
598
  let transaction: Bool = call.getBool("transaction") ?? true
574
599
  do {
575
- let res = try
576
- implementation.run(dbName,
577
- statement: statement,
578
- values: values,
579
- transaction: transaction)
580
- retHandler.rChanges(call: call, ret: res)
581
- return
600
+ if let res = try
601
+ implementation?.run(dbName,
602
+ statement: statement,
603
+ values: values,
604
+ transaction: transaction) {
605
+ retHandler.rChanges(call: call, ret: res)
606
+ return
607
+ } else {
608
+ retHandler.rChanges(
609
+ call: call, ret: ["changes": -1],
610
+ message: "Run: Does not return a valid run")
611
+ return
612
+ }
582
613
  } catch CapacitorSQLiteError.failed(let message) {
583
614
  retHandler.rChanges(
584
615
  call: call, ret: ["changes": -1],
@@ -592,9 +623,11 @@ public class CapacitorSQLitePlugin: CAPPlugin {
592
623
  }
593
624
 
594
625
  }
626
+ // swiftlint:enable function_body_length
595
627
 
596
628
  // MARK: - Query
597
629
 
630
+ // swiftlint:disable function_body_length
598
631
  @objc func query(_ call: CAPPluginCall) {
599
632
  guard let dbName = call.options["database"]
600
633
  as? String else {
@@ -622,12 +655,19 @@ public class CapacitorSQLitePlugin: CAPPlugin {
622
655
 
623
656
  }
624
657
  do {
625
- let res = try
626
- implementation.query(dbName,
627
- statement: statement,
628
- values: values)
629
- retHandler.rValues(call: call, ret: res)
630
- return
658
+ if let res = try
659
+ implementation?.query(dbName,
660
+ statement: statement,
661
+ values: values) {
662
+ retHandler.rValues(call: call, ret: res)
663
+ return
664
+ } else {
665
+ retHandler.rValues(
666
+ call: call, ret: [],
667
+ message: "Query: Does not return a valid query")
668
+ return
669
+
670
+ }
631
671
  } catch CapacitorSQLiteError.failed(let message) {
632
672
  retHandler.rValues(
633
673
  call: call, ret: [],
@@ -641,6 +681,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
641
681
  }
642
682
 
643
683
  }
684
+ // swiftlint:enable function_body_length
644
685
 
645
686
  // MARK: - isDBExists
646
687
 
@@ -653,7 +694,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
653
694
  return
654
695
  }
655
696
  do {
656
- let res = try implementation.isDBExists(dbName)
697
+ let res = try implementation?.isDBExists(dbName)
657
698
  var bRes: Bool = false
658
699
  if res == 1 {
659
700
  bRes = true
@@ -683,7 +724,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
683
724
  return
684
725
  }
685
726
  do {
686
- let res = try implementation.isDBOpen(dbName)
727
+ let res = try implementation?.isDBOpen(dbName)
687
728
  var bRes: Bool = false
688
729
  if res == 1 {
689
730
  bRes = true
@@ -712,7 +753,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
712
753
  return
713
754
  }
714
755
  do {
715
- try implementation.deleteDatabase(dbName)
756
+ try implementation?.deleteDatabase(dbName)
716
757
  retHandler.rResult(call: call)
717
758
  return
718
759
  } catch CapacitorSQLiteError.failed(let message) {
@@ -737,7 +778,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
737
778
  return
738
779
  }
739
780
  do {
740
- try implementation.isJsonValid(parsingData)
781
+ try implementation?.isJsonValid(parsingData)
741
782
  retHandler.rResult(call: call, ret: true)
742
783
  return
743
784
  } catch CapacitorSQLiteError.failed(let message) {
@@ -762,7 +803,8 @@ public class CapacitorSQLitePlugin: CAPPlugin {
762
803
  return
763
804
  }
764
805
  do {
765
- let res: [String: Int] = try implementation.importFromJson(parsingData)
806
+ let res: [String: Int] = try implementation?
807
+ .importFromJson(parsingData) ?? ["changes": -1]
766
808
  retHandler.rChanges(call: call, ret: res)
767
809
  return
768
810
  } catch CapacitorSQLiteError.failed(let message) {
@@ -808,8 +850,8 @@ public class CapacitorSQLitePlugin: CAPPlugin {
808
850
  }
809
851
 
810
852
  do {
811
- let res: [String: Any] = try implementation
812
- .exportToJson(dbName, expMode: expMode)
853
+ let res: [String: Any] = try implementation?
854
+ .exportToJson(dbName, expMode: expMode) ?? [:]
813
855
  retHandler.rJsonSQLite(call: call, ret: res)
814
856
  return
815
857
  } catch CapacitorSQLiteError.failed(let message) {
@@ -837,8 +879,8 @@ public class CapacitorSQLitePlugin: CAPPlugin {
837
879
  return
838
880
  }
839
881
  do {
840
- let res: NSNumber = try implementation
841
- .createSyncTable(dbName)
882
+ let res: NSNumber = try implementation?
883
+ .createSyncTable(dbName) ?? -1
842
884
  retHandler.rChanges(call: call,
843
885
  ret: ["changes": Int(truncating: res)])
844
886
  return
@@ -872,7 +914,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
872
914
  return
873
915
  }
874
916
  do {
875
- try implementation.setSyncDate( dbName, syncDate: syncDate)
917
+ try implementation?.setSyncDate( dbName, syncDate: syncDate)
876
918
  retHandler.rResult(call: call)
877
919
  return
878
920
  } catch CapacitorSQLiteError.failed(let message) {
@@ -896,7 +938,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
896
938
  return
897
939
  }
898
940
  do {
899
- let res: NSNumber = try implementation.getSyncDate( dbName)
941
+ let res: NSNumber = try implementation?.getSyncDate( dbName) ?? 0
900
942
  retHandler.rSyncDate(call: call,
901
943
  ret: Int64(truncating: res))
902
944
  return
@@ -928,12 +970,17 @@ public class CapacitorSQLitePlugin: CAPPlugin {
928
970
  return
929
971
  }
930
972
  do {
931
- let upgVersionDict: [Int: [String: Any]] = try
932
- implementation.addUpgradeStatement(dbName,
933
- upgrade: upgrade)
934
- versionUpgrades = ["\(dbName)": upgVersionDict]
935
- retHandler.rResult(call: call)
936
- return
973
+ if let upgVersionDict: [Int: [String: Any]] = try
974
+ implementation?.addUpgradeStatement(dbName,
975
+ upgrade: upgrade) {
976
+ versionUpgrades = ["\(dbName)": upgVersionDict]
977
+ retHandler.rResult(call: call)
978
+ return
979
+ } else {
980
+ let msg = "addUpgradeStatement: Error in returned upgVersionDict"
981
+ retHandler.rResult(call: call, message: msg)
982
+ return
983
+ }
937
984
  } catch CapacitorSQLiteError.failed(let message) {
938
985
  let msg = "addUpgradeStatement: \(message)"
939
986
  retHandler.rResult(call: call, message: msg)
@@ -952,7 +999,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
952
999
  let overwrite: Bool = call.getBool("overwrite") ?? true
953
1000
 
954
1001
  do {
955
- try implementation.copyFromAssets(overwrite: overwrite)
1002
+ try implementation?.copyFromAssets(overwrite: overwrite)
956
1003
  retHandler.rResult(call: call)
957
1004
  return
958
1005
  } catch CapacitorSQLiteError.failed(let message) {
@@ -966,6 +1013,123 @@ public class CapacitorSQLitePlugin: CAPPlugin {
966
1013
  }
967
1014
  }
968
1015
 
1016
+ // MARK: - getNCDatabasePath
1017
+
1018
+ @objc func getNCDatabasePath(_ call: CAPPluginCall) {
1019
+ guard let folderPath = call.options["path"] as? String else {
1020
+ retHandler.rPath(call: call, ret: "",
1021
+ message: "getNCDatabasePath: Must provide a folder path")
1022
+ return
1023
+ }
1024
+ guard let dbName = call.options["database"] as? String else {
1025
+ retHandler.rPath(call: call, ret: "",
1026
+ message: "getNCDatabasePath: Must provide a database name")
1027
+ return
1028
+ }
1029
+ do {
1030
+
1031
+ if let path: String = try implementation?
1032
+ .getNCDatabasePath(folderPath, dbName: dbName) {
1033
+ retHandler.rPath(call: call, ret: path)
1034
+ return
1035
+ } else {
1036
+ let msg = "getNCDatabasePath: Does not return a NC path"
1037
+ retHandler.rPath(call: call, ret: "", message: msg)
1038
+ return
1039
+
1040
+ }
1041
+ } catch CapacitorSQLiteError.failed(let message) {
1042
+ let msg = "getNCDatabasePath: \(message)"
1043
+ retHandler.rPath(call: call, ret: "", message: msg)
1044
+ return
1045
+ } catch let error {
1046
+ retHandler.rPath(call: call, ret: "",
1047
+ message: "getNCDatabasePath: \(error)")
1048
+ return
1049
+ }
1050
+ }
1051
+
1052
+ // MARK: - CreateNCConnection
1053
+
1054
+ @objc func createNCConnection(_ call: CAPPluginCall) {
1055
+ guard let dbPath = call.options["databasePath"] as? String else {
1056
+ retHandler.rResult(
1057
+ call: call,
1058
+ message: "CreateNCConnection: Must provide a database path")
1059
+ return
1060
+ }
1061
+ let version: Int = call.getInt("version") ?? 1
1062
+ do {
1063
+ try implementation?.createNCConnection(dbPath,
1064
+ version: version)
1065
+ retHandler.rResult(call: call)
1066
+ return
1067
+ } catch CapacitorSQLiteError.failed(let message) {
1068
+ let msg = "CreateNCConnection: \(message)"
1069
+ retHandler.rResult(call: call, message: msg)
1070
+ return
1071
+ } catch let error {
1072
+ retHandler.rResult(
1073
+ call: call,
1074
+ message: "CreateNCConnection: \(error)")
1075
+ return
1076
+ }
1077
+ }
1078
+
1079
+ // MARK: - CloseNCConnection
1080
+
1081
+ @objc func closeNCConnection(_ call: CAPPluginCall) {
1082
+ guard let dbPath = call.options["databasePath"] as? String else {
1083
+ retHandler.rResult(
1084
+ call: call,
1085
+ message: "CloseNCConnection: Must provide a database path")
1086
+ return
1087
+ }
1088
+ do {
1089
+ try implementation?.closeNCConnection(dbPath)
1090
+ retHandler.rResult(call: call)
1091
+ return
1092
+ } catch CapacitorSQLiteError.failed(let message) {
1093
+ let msg = "CloseNCConnection: \(message)"
1094
+ retHandler.rResult(call: call, message: msg)
1095
+ return
1096
+ } catch let error {
1097
+ retHandler.rResult(
1098
+ call: call,
1099
+ message: "CloseNCConnection: \(error)")
1100
+ return
1101
+ }
1102
+ }
1103
+
1104
+ // MARK: - IsNCDatabase
1105
+
1106
+ @objc func isNCDatabase(_ call: CAPPluginCall) {
1107
+ guard let dbPath = call.options["databasePath"] as? String else {
1108
+ retHandler.rResult(
1109
+ call: call, ret: false,
1110
+ message: "isNCDatabase: Must provide a database path")
1111
+ return
1112
+ }
1113
+ do {
1114
+ let res = try implementation?.isNCDatabase(dbPath)
1115
+ var bRes: Bool = false
1116
+ if res == 1 {
1117
+ bRes = true
1118
+ }
1119
+ retHandler.rResult(call: call, ret: bRes)
1120
+ } catch CapacitorSQLiteError.failed(let message) {
1121
+ let msg = "isNCDatabase: \(message)"
1122
+ retHandler.rResult(call: call, message: msg)
1123
+ return
1124
+ } catch let error {
1125
+ retHandler.rResult(
1126
+ call: call,
1127
+ message: "isNCDatabase: \(error)")
1128
+ return
1129
+ }
1130
+
1131
+ }
1132
+
969
1133
  // MARK: - Add Observers
970
1134
 
971
1135
  @objc func addObserversToNotificationCenter() {
@@ -992,6 +1156,14 @@ public class CapacitorSQLitePlugin: CAPPlugin {
992
1156
  return
993
1157
  }
994
1158
  }
1159
+ private func sqliteConfig() -> SqliteConfig {
1160
+ var config = SqliteConfig()
1161
+
1162
+ if let iosDatabaseLocation = getConfigValue("iosDatabaseLocation") as? String {
1163
+ config.iosDatabaseLocation = iosDatabaseLocation
1164
+ }
1165
+ return config
1166
+ }
995
1167
 
996
1168
  }
997
1169
  // swiftlint:enable type_body_length