@capacitor-community/sqlite 5.0.0 → 5.0.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p>
2
2
  <h3 align="center">SQLITE DATABASE</h3>
3
- <p align="center"><strong><code>@capacitor-community/sqlite@next</code></strong></p>
3
+ <p align="center"><strong><code>@capacitor-community/sqlite</code></strong></p>
4
4
  <br>
5
5
  <p align="center" style="font-size:50px;color:red"><strong>CAPACITOR 5</strong></p><br>
6
6
 
@@ -16,7 +16,7 @@
16
16
  <a href="https://www.npmjs.com/package/@capacitor-community/sqlite"><img src="https://img.shields.io/npm/dw/@capacitor-community/sqlite?style=flat-square" /></a>
17
17
  <a href="https://www.npmjs.com/package/@capacitor-community/sqlite"><img src="https://img.shields.io/npm/v/@capacitor-community/sqlite?style=flat-square" /></a>
18
18
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
19
- <a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-35-orange?style=flat-square" /></a>
19
+ <a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-36-orange?style=flat-square" /></a>
20
20
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
21
21
  </p>
22
22
 
@@ -48,33 +48,39 @@ npx cap sync
48
48
 
49
49
  then add plugin to main `capacitor.config.json` file:
50
50
 
51
- ```json
52
- {
53
- "appId": "com.example.app",
54
- "appName": "cap",
55
- "webDir": "dist",
56
- "bundledWebRuntime": false,
57
- "plugins": {
58
- "CapacitorSQLite": {
59
- "iosDatabaseLocation": "Library/CapacitorDatabase",
60
- "iosIsEncryption": false,
61
- "iosKeychainPrefix": "cap",
62
- "iosBiometric": {
63
- "biometricAuth": false,
64
- "biometricTitle" : "Biometric login for capacitor sqlite"
51
+ ```ts
52
+ import { CapacitorConfig } from '@capacitor/cli';
53
+
54
+ const config: CapacitorConfig = {
55
+ appId: 'com.jeep.app.ionic7.angular.sqlite',
56
+ appName: 'ionic7-angular-sqlite-starter',
57
+ webDir: 'www',
58
+ server: {
59
+ androidScheme: 'https'
60
+ },
61
+ plugins: {
62
+ CapacitorSQLite: {
63
+ iosDatabaseLocation: 'Library/CapacitorDatabase',
64
+ iosIsEncryption: true,
65
+ iosKeychainPrefix: 'angular-sqlite-app-starter',
66
+ iosBiometric: {
67
+ biometricAuth: false,
68
+ biometricTitle : "Biometric login for capacitor sqlite"
65
69
  },
66
- "androidIsEncryption": false,
67
- "androidBiometric": {
68
- "biometricAuth" : false,
69
- "biometricTitle" : "Biometric login for capacitor sqlite",
70
- "biometricSubTitle" : "Log in using your biometric"
70
+ androidIsEncryption: true,
71
+ androidBiometric: {
72
+ biometricAuth : false,
73
+ biometricTitle : "Biometric login for capacitor sqlite",
74
+ biometricSubTitle : "Log in using your biometric"
71
75
  },
72
- "electronWindowsLocation": "C:\\ProgramData\\CapacitorDatabases",
73
- "electronMacLocation": "YOUR_VOLUME/CapacitorDatabases",
74
- "electronLinuxLocation": "Databases"
76
+ electronWindowsLocation: "C:\\ProgramData\\CapacitorDatabases",
77
+ electronMacLocation: "/Volumes/Development_Lacie/Development/Databases",
78
+ electronLinuxLocation: "Databases"
75
79
  }
76
80
  }
77
- }
81
+ };
82
+ export default config;
83
+
78
84
  ```
79
85
 
80
86
  ## More Reading:
@@ -259,7 +265,7 @@ npm install --save node-fetch@2.6.7
259
265
 
260
266
  - [Ionic/Angular Usage Documentation](https://github.com/capacitor-community/sqlite/blob/master/docs/Ionic-Angular-Usage.md)
261
267
 
262
- - [ionic-angular-sqlite-starter](https://github.com/jepiqueau/ionic-angular-sqlite-starter) Ionic 6 Angular SQLite CRUD operations.
268
+ - [ionic7-angular-sqlite-starter](https://github.com/jepiqueau/ionic7-angular-sqlite-starter) Ionic 7 Angular 16 Capacitor 5 SQLite CRUD operations.
263
269
 
264
270
  - [angular-sqlite-app-starter](https://github.com/jepiqueau/angular-sqlite-app-starter) This one is now more for testing the issues.
265
271
 
@@ -279,6 +285,10 @@ npm install --save node-fetch@2.6.7
279
285
 
280
286
  - [react-vite-sqlite-app](https://github.com/jepiqueau/react-vite-sqlite-app)
281
287
 
288
+ ### Ionic/React Capacitor SQLite + TypeORM Example App
289
+
290
+ - [capacitor-sqlite-react-typeorm-app](https://github.com/cosentino/capacitor-sqlite-react-typeorm-app)
291
+
282
292
  ### Ionic/Vue
283
293
 
284
294
  - [Ionic/Vue Usage Documentation](https://github.com/capacitor-community/sqlite/blob/master/docs/Ionic-Vue-Usage.md)
@@ -352,6 +362,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
352
362
  <a href="https://github.com/folsze" title="folsze"><img src="https://github.com/folsze.png?size=100" width="50" height="50" /></a>
353
363
  <a href="https://github.com/pranav-singhal" title="pranav-singhal"><img src="https://github.com/pranav-singhal.png?size=100" width="50" height="50" /></a>
354
364
  <a href="https://github.com/beligatclement" title="beligatclement"><img src="https://github.com/beligatclement.png?size=100" width="50" height="50" /></a>
365
+ <a href="https://github.com/cosentino" title="cosentino"><img src="https://avatars.githubusercontent.com/u/376903?s=48&v=4" width="50" height="50" /></a>
355
366
  </p>
356
367
 
357
368
 
@@ -8,6 +8,7 @@ import static android.database.Cursor.FIELD_TYPE_STRING;
8
8
 
9
9
  import android.content.Context;
10
10
  import android.content.SharedPreferences;
11
+ import android.os.Build;
11
12
  import android.util.Log;
12
13
  import androidx.sqlite.db.SimpleSQLiteQuery;
13
14
  import androidx.sqlite.db.SupportSQLiteDatabase;
@@ -22,6 +23,7 @@ import java.io.File;
22
23
  import java.text.SimpleDateFormat;
23
24
  import java.util.ArrayList;
24
25
  import java.util.Arrays;
26
+ import java.util.Base64;
25
27
  import java.util.Collections;
26
28
  import java.util.Date;
27
29
  import java.util.Dictionary;
@@ -795,7 +797,12 @@ public class Database {
795
797
  row.put(colName, c.getDouble(index));
796
798
  break;
797
799
  case FIELD_TYPE_BLOB:
798
- row.put(colName, c.getBlob(index));
800
+ // row.put(colName, c.getBlob(index));
801
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
802
+ row.put(colName, Base64.getEncoder().encodeToString(c.getBlob(index)));
803
+ } else {
804
+ row.put(colName, JSONObject.NULL);
805
+ }
799
806
  break;
800
807
  case FIELD_TYPE_NULL:
801
808
  row.put(colName, JSONObject.NULL);
@@ -909,13 +909,15 @@ class UtilsSQLCipher {
909
909
  let val: Double = sqlite3_column_double(handle, index)
910
910
  rowData[String(cString: name)] = val
911
911
  case SQLITE_BLOB:
912
- let data = sqlite3_column_blob(handle, index)
913
- let size = sqlite3_column_bytes(handle, index)
914
- let val = NSData(bytes: data, length: Int(size))
915
- // Convert to string
916
- let strVal: String = String(decoding: val,
917
- as: UTF8.self)
918
- rowData[String(cString: name)] = strVal
912
+ if let dataBlob = sqlite3_column_blob(handle, index){
913
+ let dataBlobLength = sqlite3_column_bytes(handle,index)
914
+ let data = Data(bytes: dataBlob,
915
+ count:Int(dataBlobLength))
916
+ rowData[String(cString: name)] = data.base64EncodedString()
917
+ } else {
918
+ rowData[String(cString: name)] = NSNull()
919
+ }
920
+
919
921
  case SQLITE_TEXT:
920
922
  let buffer = sqlite3_column_text(handle, index)
921
923
  if let mBuffer = buffer {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/sqlite",
3
- "version": "5.0.0",
3
+ "version": "5.0.2",
4
4
  "description": "Community plugin for native & electron SQLite databases",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -95,6 +95,6 @@
95
95
  }
96
96
  },
97
97
  "dependencies": {
98
- "jeep-sqlite": "^2.3.4"
98
+ "jeep-sqlite": "^2.3.6"
99
99
  }
100
100
  }