@op-engineering/op-sqlite 2.0.0 → 2.0.1

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
@@ -20,7 +20,7 @@ You can find the [benchmarking code in the example app](https://github.com/OP-En
20
20
 
21
21
  ![benchmark](benchmark.png)
22
22
 
23
- Memory consumption is also is also 1/4 compared to `react-native-quick-sqlite`. This query used to take 1.2 GB of peak memory usage, and now runs in 250mbs.
23
+ Memory consumption is also 1/4 compared to `react-native-quick-sqlite`. This query used to take 1.2 GB of peak memory usage, and now runs in 250mbs.
24
24
 
25
25
  # Encryption
26
26
 
@@ -39,8 +39,8 @@ You can use relative location to navigate in and out of the **default location**
39
39
  ```ts
40
40
  import { open } from '@op-engineering/op-sqlite';
41
41
 
42
- const largeDb = open({
43
- name: 'largeDB',
42
+ const db = open({
43
+ name: 'myDB',
44
44
  location: '../files/databases',
45
45
  });
46
46
  ```
@@ -53,20 +53,42 @@ You can also pass absolute paths to completely change the location of the databa
53
53
 
54
54
  ```ts
55
55
  import {
56
+ IOS_LIBRARY_PATH, // Default iOS
56
57
  IOS_DOCUMENT_PATH,
57
- IOS_LIBRARY_PATH,
58
- ANDROID_DATABASE_PATH,
58
+ ANDROID_DATABASE_PATH, // Default Android
59
59
  ANDROID_FILES_PATH,
60
60
  ANDROID_EXTERNAL_FILES_PATH,
61
61
  open,
62
62
  } from '@op-engineering/op-sqlite';
63
63
 
64
- const largeDb = open({
65
- name: 'largeDB',
64
+ const db = open({
65
+ name: 'myDb',
66
66
  location: Platform.OS === 'ios' ? IOS_LIBRARY_PATH : ANDROID_DATABASE_PATH,
67
67
  });
68
68
  ```
69
69
 
70
+ Here is an example if you want to access the SD card app's directory:
71
+
72
+ ```ts
73
+ const db = open({
74
+ name: 'myDB',
75
+ location:
76
+ Platform.OS === 'ios' ? IOS_LIBRARY_PATH : ANDROID_EXTERNAL_FILES_PATH,
77
+ });
78
+ ```
79
+
80
+ You can even drill down:
81
+
82
+ ```ts
83
+ const db = open({
84
+ name: 'myDB',
85
+ location:
86
+ Platform.OS === 'ios'
87
+ ? IOS_LIBRARY_PATH
88
+ : `${ANDROID_EXTERNAL_FILES_PATH}/dbs/`,
89
+ });
90
+ ```
91
+
70
92
  ## In-memory
71
93
 
72
94
  Using SQLite in-memory mode is supported by passing a `':memory:'` as a location:
package/ios/OPSQLite.mm CHANGED
@@ -7,8 +7,19 @@
7
7
 
8
8
  @implementation OPSQLite
9
9
 
10
+ @synthesize bridge=_bridge;
11
+
10
12
  RCT_EXPORT_MODULE(OPSQLite)
11
13
 
14
+ - (void)setBridge:(RCTBridge *)bridge {
15
+ _bridge = bridge;
16
+ }
17
+
18
+ + (BOOL)requiresMainQueueSetup
19
+ {
20
+ return YES;
21
+ }
22
+
12
23
  - (NSDictionary *)constantsToExport {
13
24
  NSArray *libraryPaths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, true);
14
25
  NSString *libraryPath = [libraryPaths objectAtIndex:0];
@@ -22,8 +33,7 @@ RCT_EXPORT_MODULE(OPSQLite)
22
33
  }
23
34
 
24
35
  RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
25
- RCTBridge *bridge = [RCTBridge currentBridge];
26
- RCTCxxBridge *cxxBridge = (RCTCxxBridge *)bridge;
36
+ RCTCxxBridge *cxxBridge = (RCTCxxBridge *)_bridge;
27
37
  if (cxxBridge == nil) {
28
38
  return @false;
29
39
  }
@@ -35,7 +45,7 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
35
45
  return @false;
36
46
  }
37
47
  auto &runtime = *jsiRuntime;
38
- auto callInvoker = bridge.jsCallInvoker;
48
+ auto callInvoker = _bridge.jsCallInvoker;
39
49
 
40
50
  // Get appGroupID value from Info.plist using key "AppGroup"
41
51
  NSString *appGroupID = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"OPSQLite_AppGroup"];
@@ -58,8 +68,6 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
58
68
  }
59
69
 
60
70
  opsqlite::install(runtime, callInvoker, [documentPath UTF8String]);
61
-
62
- NSLog(@"OP-SQLite initialized");
63
71
  return @true;
64
72
  }
65
73
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@op-engineering/op-sqlite",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Next generation SQLite for React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",