@capacitor-community/sqlite 3.3.3-3 → 3.3.3-4

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.
@@ -197,6 +197,22 @@ enum CapacitorSQLiteError: Error {
197
197
  }
198
198
  }
199
199
 
200
+ // MARK: - getUrl
201
+
202
+ @objc public func getUrl(_ dbName: String) throws -> String {
203
+ let mDbName = CapacitorSQLite.getDatabaseName(dbName: dbName)
204
+ guard let mDb: Database = dbDict[mDbName] else {
205
+ let msg = "Connection to \(mDbName) not available"
206
+ throw CapacitorSQLiteError.failed(message: msg)
207
+ }
208
+ do {
209
+ let res: String = try mDb.getUrl()
210
+ return res
211
+ } catch DatabaseError.close(let message) {
212
+ throw CapacitorSQLiteError.failed(message: message)
213
+ }
214
+ }
215
+
200
216
  // MARK: - GetVersion
201
217
 
202
218
  @objc public func getVersion(_ dbName: String) throws -> NSNumber {
@@ -827,7 +843,7 @@ enum CapacitorSQLiteError: Error {
827
843
 
828
844
  @objc func getDatabaseList() throws -> [String] {
829
845
  do {
830
- let aPath: String = try UtilsFile.getDatabasesPath()
846
+ let aPath: String = try (UtilsFile.getFolderURL(folderPath: databaseLocation)).path
831
847
  // get the database files
832
848
  let dbList: [String] = try UtilsFile.getFileList(path: aPath, ext: ".db")
833
849
  return dbList
@@ -12,6 +12,7 @@ CAP_PLUGIN(CapacitorSQLitePlugin, "CapacitorSQLite",
12
12
  CAP_PLUGIN_METHOD(getNCDatabasePath, CAPPluginReturnPromise);
13
13
  CAP_PLUGIN_METHOD(open, CAPPluginReturnPromise);
14
14
  CAP_PLUGIN_METHOD(close, CAPPluginReturnPromise);
15
+ CAP_PLUGIN_METHOD(getUrl, CAPPluginReturnPromise);
15
16
  CAP_PLUGIN_METHOD(getVersion, CAPPluginReturnPromise);
16
17
  CAP_PLUGIN_METHOD(execute, CAPPluginReturnPromise);
17
18
  CAP_PLUGIN_METHOD(executeSet, CAPPluginReturnPromise);
@@ -207,6 +207,39 @@ public class CapacitorSQLitePlugin: CAPPlugin {
207
207
  }
208
208
  }
209
209
 
210
+ // MARK: - GetUrl
211
+
212
+ @objc func getUrl(_ call: CAPPluginCall) {
213
+ guard let dbName = call.options["database"] as? String else {
214
+ retHandler.rResult(
215
+ call: call,
216
+ message: "GetUrl: Must provide a database name")
217
+ return
218
+ }
219
+ do {
220
+ let res: String = try implementation?.getUrl(dbName) ?? ""
221
+ if res.count > 0 {
222
+ retHandler.rUrl(call: call, ret: res)
223
+ return
224
+ } else {
225
+ retHandler.rUrl(
226
+ call: call, ret: "",
227
+ message: "getUrl: No path returned")
228
+ return
229
+ }
230
+ } catch CapacitorSQLiteError.failed(let message) {
231
+ retHandler.rUrl(
232
+ call: call, ret: "",
233
+ message: "getUrl: \(message)")
234
+ return
235
+ } catch let error {
236
+ retHandler.rUrl(
237
+ call: call, ret: "",
238
+ message: "getUrl: \(error)")
239
+ return
240
+ }
241
+ }
242
+
210
243
  // MARK: - getVersion
211
244
 
212
245
  @objc func getVersion(_ call: CAPPluginCall) {
@@ -81,6 +81,12 @@ class Database {
81
81
  return ncDB
82
82
  }
83
83
 
84
+ // MARK: - getUrl
85
+
86
+ func getUrl () -> String {
87
+ return path
88
+ }
89
+
84
90
  // MARK: - Open
85
91
 
86
92
  // swiftlint:disable cyclomatic_complexity
@@ -106,4 +106,16 @@ class ReturnHandler {
106
106
  return
107
107
  }
108
108
  }
109
+ // MARK: - rUrl
110
+
111
+ func rUrl(call: CAPPluginCall, ret: String,
112
+ message: String? = nil) {
113
+ if let intMessage = message {
114
+ call.reject(intMessage)
115
+ return
116
+ } else {
117
+ call.resolve(["url": ret])
118
+ return
119
+ }
120
+ }
109
121
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/sqlite",
3
- "version": "3.3.3-3",
3
+ "version": "3.3.3-4",
4
4
  "description": "Community plugin for native & electron SQLite databases",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",