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,21 +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
-
- If you want to run the example project on android, you will have to change the paths on the android/CMakeLists.txt file, they are already there, just uncomment them.
37
-
38
-
## Use TypeORM
39
-
40
-
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).
41
-
42
-
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.
43
33
44
34
## API
45
35
46
-
It is also possible to directly execute SQL against the db:
// Import as early as possible, auto-installs bindings
80
86
import'react-native-quick-sqlite';
81
87
82
88
// `sqlite` is a globally registered object, so you can directly call it from anywhere in your javascript
@@ -128,9 +134,25 @@ if (!result.status) {
128
134
}
129
135
```
130
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
+
147
+
## Use TypeORM
148
+
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).
150
+
151
+
Follow the instructions to make TypeORM work with React Native (enable decorators, configure babel, etc), then apply the example patch via patch-package.
152
+
131
153
## Learn React Native JSI
132
154
133
-
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:[email protected]?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:[email protected]?subject=Freelance)!
0 commit comments