You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library uses [JSI](https://formidable.com/blog/2019/jsi-jsc-part-2) to directly call C++ code from JS. It provides a low-level API to execute SQL queries, therefore I recommend you use it with TypeORM.
24
+
This library provides a low-level API to execute SQL queries, fast bindings via [JSI](https://formidable.com/blog/2019/jsi-jsc-part-2).
25
25
26
26
Inspired/compatible with [react-native-sqlite-storage](https://github.com/andpor/react-native-sqlite-storage) and [react-native-sqlite2](https://github.com/craftzdog/react-native-sqlite-2).
27
27
@@ -30,15 +30,9 @@ Inspired/compatible with [react-native-sqlite-storage](https://github.com/andpor
30
30
-**Javascript cannot represent intergers larger than 53 bits**, be careful when loading data if it came from other systems. [Read more](https://github.com/ospfranco/react-native-quick-sqlite/issues/16#issuecomment-1018412991).
31
31
-**It's not possible to use a browser to debug a JSI app**, use [Flipper](https://github.com/facebook/flipper) (for android Flipper also has SQLite Database explorer).
32
32
- Your app will now include C++, you will need to install the NDK on your machine for android.
33
-
- This library supports SQLite BLOBs which are mapped to JS ArrayBuffers, check out the sample project on how to use it
34
-
- From version 2.0.0 onwards errors are no longer thrown on invalid SQL statements. The response contains a `status` number, `0` signals correct execution, `1` signals an error.
35
-
- From version 3.0.0 onwards no JS errors are thown, every operation returns an object with a `status` field.
36
-
- On older react-native versions you might face weird NDK/SDK/Cmake errors, the latest version is tested against RN 0.67.3
37
33
38
34
## API
39
35
40
-
It is also possible to directly execute SQL against the db:
//You need to import this once in your app, it installs the binding on android
85
+
//Import as early as possible, auto-installs bindings
84
86
import'react-native-quick-sqlite';
85
87
86
88
// `sqlite` is a globally registered object, so you can directly call it from anywhere in your javascript
@@ -132,15 +134,25 @@ if (!result.status) {
132
134
}
133
135
```
134
136
137
+
Async versions are also available if you have too much SQL to execute
138
+
139
+
```ts
140
+
sqlite.asyncExecuteSql('myDatabase', 'SELECT * FROM "User";', [], (result) => {
141
+
if (result.status===0) {
142
+
console.log('users', result.rows);
143
+
}
144
+
});
145
+
```
146
+
135
147
## Use TypeORM
136
148
137
149
This package offers a low-level API to raw execute SQL queries. I strongly recommend to use [TypeORM](https://github.com/typeorm/typeorm) (with [patch-package](https://github.com/ds300/patch-package)). TypeORM already has a sqlite-storage driver. In the `example` project on the `patch` folder you can a find a [patch for TypeORM](https://github.com/ospfranco/react-native-quick-sqlite/blob/main/example/patches/typeorm%2B0.2.31.patch).
138
150
139
-
Follow the instructions to make TypeORM work with React Native (enable decorators, configure babel, etc), then apply the patch via patch-package and you should be good to go.
151
+
Follow the instructions to make TypeORM work with React Native (enable decorators, configure babel, etc), then apply the example patch via patch-package.
140
152
141
153
## Learn React Native JSI
142
154
143
-
If you want to learn how to make your own JSI module buy my [JSI/C++ Cheatsheet](http://ospfranco.gumroad.com/l/IeeIvl), I'm also available for [freelance work](mailto:ospfranco@protonmail.com?subject=Freelance)!
155
+
If you want to learn how to make your own JSI module buy my [JSI/C++ Cheatsheet](http://ospfranco.gumroad.com/l/jsi_guide), I'm also available for [freelance work](mailto:ospfranco@protonmail.com?subject=Freelance)!
0 commit comments