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
Copy file name to clipboardExpand all lines: README.md
+24-17Lines changed: 24 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -135,14 +135,13 @@ openDatabase(
135
135
136
136
# Usage
137
137
138
-
Import as early as possible, auto-installs bindings in a thread-safe manner.
138
+
Just import the package and fire away
139
139
140
140
```typescript
141
141
// Thanks to @mrousavy for this installation method, see one example: https://github.com/mrousavy/react-native-mmkv/blob/75b425db530e26cf10c7054308583d03ff01851f/src/createMMKV.ts#L56
The basic query is **synchronous**, it will block rendering on large operations, below there are async versions.
156
155
157
156
```typescript
158
-
let { status, rows } =sqlite.executeSql(
157
+
let { status, rows } =QuickSQLite.executeSql(
159
158
'myDatabase',
160
159
'SELECT somevalue FROM sometable'
161
160
);
@@ -165,7 +164,7 @@ if (!status) {
165
164
});
166
165
}
167
166
168
-
let { status, rowsAffected } =sqlite.executeSql(
167
+
let { status, rowsAffected } =QuickSQLite.executeSql(
169
168
'myDatabase',
170
169
'UPDATE sometable SET somecolumn = ? where somekey = ?',
171
170
[0, 1]
@@ -182,7 +181,7 @@ Transactions are supported. However, due to the library being opinionated and mo
182
181
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.
183
182
184
183
```typescript
185
-
sqlite.transaction('myDatabase', (tx) => {
184
+
QuickSQLite.transaction('myDatabase', (tx) => {
186
185
const {
187
186
status,
188
187
} =tx.executeSql('UPDATE sometable SET somecolumn = ? where somekey = ?', [
@@ -209,7 +208,7 @@ const commands = [
209
208
('INSERT INTO TABLE TEST (id) VALUES (?)', [2])
210
209
][('INSERT INTO TABLE TEST (id) VALUES (?)', [[3], [4], [5], [6]])],
211
210
];
212
-
const result =sqlite.executeSqlBatch('myDatabase', commands);
211
+
const result =QuickSQLite.executeSqlBatch('myDatabase', commands);
@@ -225,7 +224,7 @@ sqlite datatypes. When fetching data directly from tables or views linked to tab
225
224
to identify the table declared types:
226
225
227
226
```typescript
228
-
let { status, metadata } =sqlite.executeSql(
227
+
let { status, metadata } =QuickSQLite.executeSql(
229
228
'myDatabase',
230
229
'SELECT int_column_1, bol_column_2 FROM sometable'
231
230
);
@@ -244,7 +243,7 @@ if (!status) {
244
243
You might have too much SQL to 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.
245
244
246
245
```ts
247
-
sqlite.asyncExecuteSql(
246
+
QuickSQLite.asyncExecuteSql(
248
247
'myDatabase',
249
248
'SELECT * FROM "User";',
250
249
[],
@@ -270,21 +269,29 @@ SQLite have a limit for attached databases: A default of 10, and a global max of
const result =sqlite.attach('mainDatabase', 'statistics', 'stats', '../databases',);
272
+
const result =QuickSQLite.attach(
273
+
'mainDatabase',
274
+
'statistics',
275
+
'stats',
276
+
'../databases'
277
+
);
274
278
275
279
// Database is attached sucefully
276
-
if(!result.status) {
277
-
const data =sqlite.executeSql('mainDatabase', 'SELECT * FROM some_table_from_mainschema a INNER JOIN stats.some_table b on a.id_column = b.id_column');
280
+
if (!result.status) {
281
+
const data =QuickSQLite.executeSql(
282
+
'mainDatabase',
283
+
'SELECT * FROM some_table_from_mainschema a INNER JOIN stats.some_table b on a.id_column = b.id_column'
0 commit comments