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 embeds the latest version of SQLite and provides a low-level API to execute SQL queries, fast bindings via [JSI](https://formidable.com/blog/2019/jsi-jsc-part-2). By using the latest version of SQLite instead of the phone's you get all the latest security fixes and also all new features.
25
+
Quick SQLite embeds the latest version of SQLite and provides a low-level API to execute SQL queries, uses fast bindings via [JSI](https://formidable.com/blog/2019/jsi-jsc-part-2). By using an embedded SQLite you get access the latest security patches and latest features.
28
26
29
27
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).
30
28
@@ -57,14 +55,11 @@ interface QueryResult {
57
55
/**
58
56
* Column metadata
59
57
* Describes some information about columns fetched by the query
58
+
* columnDeclaredType - declared column type for this column, when fetched directly from a table or a View resulting from a table column. "UNKNOWN" for dynamic values, like function returned ones.
60
59
*/
61
-
declaretypeColumnMetadata= {
62
-
/** The name used for this column for this resultset */
60
+
interfaceColumnMetadata = {
63
61
columnName:string;
64
-
/** The declared column type for this column, when fetched directly from a table or a View resulting from a table column. "UNKNOWN" for dynamic values, like function returned ones. */
65
62
columnDeclaredType:string;
66
-
/**
67
-
* The index for this column for this resultset*/
68
63
columnIndex:number;
69
64
};
70
65
@@ -108,13 +103,13 @@ interface ISQLite {
108
103
109
104
# Usage
110
105
106
+
Import as early as possible, auto-installs bindings in a thread-safe manner.
107
+
111
108
```typescript
112
-
// Import as early as possible, auto-installs bindings.
113
109
// Thanks to @mrousavy for this installation method, see one example: https://github.com/mrousavy/react-native-mmkv/blob/75b425db530e26cf10c7054308583d03ff01851f/src/createMMKV.ts#L56
114
110
import'react-native-quick-sqlite';
115
111
116
-
// `sqlite` is a globally registered object, so you can directly call it from anywhere in your javascript
117
-
// the import on the top of the file only registers typescript types but it is not mandatory
112
+
// Afterwards `sqlite` is a globally registered object, so you can directly call it from anywhere in your javascript
In some scenarios, dynamic applications may need to get some metadata information about the returned resultset.
150
-
This can be done testing the returned data directly, but in some cases may not be enough, like when data is stored outside
151
-
storage datatypes, like booleans or datetimes. When fetching data directly from tables or views linked to table columns, SQLite is able
152
-
to identify the table declared types:
146
+
### Transactions
147
+
148
+
Transactions are supported. However, due to the library being opionionated and mostly not throwing errors you need to return a boolean (true for correct exceution, false for incorrect execution) to either commit or rollback the transaction.
149
+
150
+
JSI bindings are fast but there is still some overhead calling `executeSql` for single queries, if you want to execute a large set of commands as fast as possible you should use the `executeSqlBatch` method below, it still uses transactions, but only transmits data between JS and native once.
153
151
154
152
```typescript
155
-
let result =sqlite.executeSql(
156
-
'myDatabase',
157
-
'SELECT int_column_1, bol_column_2 FROM sometable'
You might have too much SQL too process and it will cause your application to freeze. There are async versions for some of the operations. This will offload the SQLite processing to a different thread.
188
213
189
214
```ts
190
-
sqlite.asyncExecuteSql('myDatabase', 'SELECT * FROM "User";', [], (result) => {
0 commit comments