expo-sqlite 12.0.0 → 12.2.0
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/CHANGELOG.md +23 -0
- package/android/build.gradle +4 -4
- package/android/src/main/cpp/NativeStatementBinding.cpp +19 -8
- package/android/src/main/cpp/NativeStatementBinding.h +2 -14
- package/android/src/main/java/expo/modules/sqlite/NativeStatementBinding.kt +4 -3
- package/android/src/main/java/expo/modules/sqlite/SQLiteModuleNext.kt +19 -12
- package/android/src/main/jniLibs/arm64-v8a/libcrsqlite.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libcrsqlite.so +0 -0
- package/android/src/main/jniLibs/x86/libcrsqlite.so +0 -0
- package/android/src/main/jniLibs/x86_64/libcrsqlite.so +0 -0
- package/build/SQLite.d.ts +2 -2
- package/build/SQLite.d.ts.map +1 -1
- package/build/SQLite.js.map +1 -1
- package/build/SQLite.types.d.ts +3 -2
- package/build/SQLite.types.d.ts.map +1 -1
- package/build/SQLite.types.js.map +1 -1
- package/build/next/Database.d.ts +91 -73
- package/build/next/Database.d.ts.map +1 -1
- package/build/next/Database.js +24 -25
- package/build/next/Database.js.map +1 -1
- package/build/next/NativeDatabase.d.ts +1 -1
- package/build/next/NativeDatabase.js.map +1 -1
- package/build/next/NativeStatement.d.ts +17 -14
- package/build/next/NativeStatement.d.ts.map +1 -1
- package/build/next/NativeStatement.js.map +1 -1
- package/build/next/Statement.d.ts +65 -43
- package/build/next/Statement.d.ts.map +1 -1
- package/build/next/Statement.js +76 -27
- package/build/next/Statement.js.map +1 -1
- package/build/next/hooks.d.ts +25 -0
- package/build/next/hooks.d.ts.map +1 -1
- package/build/next/hooks.js +39 -11
- package/build/next/hooks.js.map +1 -1
- package/ios/SQLiteModuleNext.swift +52 -35
- package/package.json +2 -2
- package/src/SQLite.ts +2 -1
- package/src/SQLite.types.ts +5 -2
- package/src/next/Database.ts +111 -92
- package/src/next/NativeDatabase.ts +1 -1
- package/src/next/NativeStatement.ts +25 -14
- package/src/next/Statement.ts +133 -66
- package/src/next/hooks.tsx +40 -12
- package/android/src/main/jniLibs/arm64/libcrsqlite.so +0 -0
package/build/next/Database.d.ts
CHANGED
|
@@ -7,8 +7,9 @@ export { OpenOptions };
|
|
|
7
7
|
*/
|
|
8
8
|
export declare class Database {
|
|
9
9
|
readonly dbName: string;
|
|
10
|
+
readonly options: OpenOptions;
|
|
10
11
|
private readonly nativeDatabase;
|
|
11
|
-
constructor(dbName: string, nativeDatabase: NativeDatabase);
|
|
12
|
+
constructor(dbName: string, options: OpenOptions, nativeDatabase: NativeDatabase);
|
|
12
13
|
/**
|
|
13
14
|
* Asynchronous call to return whether the database is currently in a transaction.
|
|
14
15
|
*/
|
|
@@ -28,7 +29,6 @@ export declare class Database {
|
|
|
28
29
|
* Prepare a SQL statement.
|
|
29
30
|
*
|
|
30
31
|
* @param source A string containing the SQL query.
|
|
31
|
-
* @returns A `Statement` object.
|
|
32
32
|
*/
|
|
33
33
|
prepareAsync(source: string): Promise<Statement>;
|
|
34
34
|
/**
|
|
@@ -85,7 +85,8 @@ export declare class Database {
|
|
|
85
85
|
* Execute all SQL queries in the supplied string.
|
|
86
86
|
*
|
|
87
87
|
* > **Note:** The queries are not escaped for you! Be careful when constructing your queries.
|
|
88
|
-
*
|
|
88
|
+
*
|
|
89
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
|
|
89
90
|
*
|
|
90
91
|
* @param source A string containing all the SQL queries.
|
|
91
92
|
*/
|
|
@@ -93,125 +94,137 @@ export declare class Database {
|
|
|
93
94
|
/**
|
|
94
95
|
* Prepare a SQL statement.
|
|
95
96
|
*
|
|
96
|
-
* > **Note:** Running heavy tasks with this function can block the JavaScript thread
|
|
97
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
|
|
97
98
|
*
|
|
98
99
|
* @param source A string containing the SQL query.
|
|
99
|
-
* @returns A `Statement` object.
|
|
100
100
|
*/
|
|
101
101
|
prepareSync(source: string): Statement;
|
|
102
102
|
/**
|
|
103
103
|
* Execute a transaction and automatically commit/rollback based on the `task` result.
|
|
104
104
|
*
|
|
105
|
-
* > **Note:** Running heavy tasks with this function can block the JavaScript thread
|
|
105
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
|
|
106
106
|
*
|
|
107
107
|
* @param task An async function to execute within a transaction.
|
|
108
108
|
*/
|
|
109
109
|
transactionSync(task: () => void): void;
|
|
110
110
|
/**
|
|
111
|
-
* Shorthand for `prepareAsync` and `Statement.runAsync
|
|
112
|
-
* Unlike `Statement.runAsync
|
|
113
|
-
*
|
|
114
|
-
* > **Note:** Running heavy tasks with this function can block the JavaScript thread, affecting performance.
|
|
115
|
-
*
|
|
111
|
+
* Shorthand for [`prepareAsync()`](#prepareasyncsource) and [`Statement.runAsync()`](#runasyncparams).
|
|
112
|
+
* Unlike [`Statement.runAsync()`](#runasyncparams), this method finalizes the statement after execution.
|
|
116
113
|
* @param source A string containing the SQL query.
|
|
117
|
-
* @param params
|
|
114
|
+
* @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`BindValue`](#bindvalue) for more information about binding values.
|
|
118
115
|
*/
|
|
119
|
-
runAsync(source: string, ...params: VariadicBindParams): Promise<RunResult>;
|
|
120
116
|
runAsync(source: string, params: BindParams): Promise<RunResult>;
|
|
121
117
|
/**
|
|
122
|
-
*
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
*
|
|
118
|
+
* @hidden
|
|
119
|
+
*/
|
|
120
|
+
runAsync(source: string, ...params: VariadicBindParams): Promise<RunResult>;
|
|
121
|
+
/**
|
|
122
|
+
* Shorthand for [`prepareAsync()`](#prepareasyncsource) and [`Statement.getAsync()`](#getasyncparams).
|
|
123
|
+
* Unlike [`Statement.getAsync()`](#getasyncparams), this method finalizes the statement after execution.
|
|
127
124
|
* @param source A string containing the SQL query.
|
|
128
|
-
* @param params
|
|
125
|
+
* @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`BindValue`](#bindvalue) for more information about binding values.
|
|
129
126
|
*/
|
|
130
|
-
getAsync<T>(source: string, ...params: VariadicBindParams): Promise<T | null>;
|
|
131
127
|
getAsync<T>(source: string, params: BindParams): Promise<T | null>;
|
|
132
128
|
/**
|
|
133
|
-
*
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
*
|
|
129
|
+
* @hidden
|
|
130
|
+
*/
|
|
131
|
+
getAsync<T>(source: string, ...params: VariadicBindParams): Promise<T | null>;
|
|
132
|
+
/**
|
|
133
|
+
* Shorthand for [`prepareAsync()`](#prepareasyncsource) and [`Statement.eachAsync()`](#eachasyncparams).
|
|
134
|
+
* Unlike [`Statement.eachAsync()`](#eachasyncparams), this method finalizes the statement after execution.
|
|
138
135
|
* @param source A string containing the SQL query.
|
|
139
|
-
* @param params
|
|
136
|
+
* @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`BindValue`](#bindvalue) for more information about binding values.
|
|
140
137
|
*/
|
|
141
|
-
eachAsync<T>(source: string, ...params: VariadicBindParams): AsyncIterableIterator<T>;
|
|
142
138
|
eachAsync<T>(source: string, params: BindParams): AsyncIterableIterator<T>;
|
|
143
139
|
/**
|
|
144
|
-
*
|
|
145
|
-
|
|
140
|
+
* @hidden
|
|
141
|
+
*/
|
|
142
|
+
eachAsync<T>(source: string, ...params: VariadicBindParams): AsyncIterableIterator<T>;
|
|
143
|
+
/**
|
|
144
|
+
* Shorthand for [`prepareAsync()`](#prepareasyncsource) and [`Statement.allAsync()`](#allasyncparams).
|
|
145
|
+
* Unlike [`Statement.allAsync()`](#allasyncparams), this method finalizes the statement after execution.
|
|
146
|
+
* @param source A string containing the SQL query.
|
|
147
|
+
* @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`BindValue`](#bindvalue) for more information about binding values.
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* // For unnamed parameters, you pass values in an array.
|
|
151
|
+
* db.allAsync('SELECT * FROM test WHERE intValue = ? AND name = ?', [1, 'Hello']);
|
|
146
152
|
*
|
|
147
|
-
*
|
|
153
|
+
* // For unnamed parameters, you pass values in variadic arguments.
|
|
154
|
+
* db.allAsync('SELECT * FROM test WHERE intValue = ? AND name = ?', 1, 'Hello');
|
|
148
155
|
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
156
|
+
* // For named parameters, you should pass values in object.
|
|
157
|
+
* db.allAsync('SELECT * FROM test WHERE intValue = $intValue AND name = $name', { $intValue: 1, $name: 'Hello' });
|
|
158
|
+
* ```
|
|
151
159
|
*/
|
|
152
|
-
allAsync<T>(source: string, ...params: VariadicBindParams): Promise<T[]>;
|
|
153
160
|
allAsync<T>(source: string, params: BindParams): Promise<T[]>;
|
|
154
161
|
/**
|
|
155
|
-
*
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
*
|
|
162
|
+
* @hidden
|
|
163
|
+
*/
|
|
164
|
+
allAsync<T>(source: string, ...params: VariadicBindParams): Promise<T[]>;
|
|
165
|
+
/**
|
|
166
|
+
* Shorthand for [`prepareAsync()`](#prepareasyncsource) and [`Statement.runSync()`](#runsyncparams).
|
|
167
|
+
* Unlike [`Statement.runSync()`](#runsyncparams), this method finalizes the statement after execution.
|
|
168
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
|
|
160
169
|
* @param source A string containing the SQL query.
|
|
161
|
-
* @param params
|
|
170
|
+
* @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`BindValue`](#bindvalue) for more information about binding values.
|
|
162
171
|
*/
|
|
163
|
-
runSync(source: string, ...params: VariadicBindParams): RunResult;
|
|
164
172
|
runSync(source: string, params: BindParams): RunResult;
|
|
165
173
|
/**
|
|
166
|
-
*
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
*
|
|
174
|
+
* @hidden
|
|
175
|
+
*/
|
|
176
|
+
runSync(source: string, ...params: VariadicBindParams): RunResult;
|
|
177
|
+
/**
|
|
178
|
+
* Shorthand for [`prepareAsync()`](#prepareasyncsource) and [`Statement.getSync()`](#getsyncparams).
|
|
179
|
+
* Unlike [`Statement.getSync()`](#getsyncparams), this method finalizes the statement after execution.
|
|
180
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
|
|
171
181
|
* @param source A string containing the SQL query.
|
|
172
|
-
* @param params
|
|
182
|
+
* @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`BindValue`](#bindvalue) for more information about binding values.
|
|
173
183
|
*/
|
|
174
|
-
getSync<T>(source: string, ...params: VariadicBindParams): T | null;
|
|
175
184
|
getSync<T>(source: string, params: BindParams): T | null;
|
|
176
185
|
/**
|
|
177
|
-
*
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
*
|
|
186
|
+
* @hidden
|
|
187
|
+
*/
|
|
188
|
+
getSync<T>(source: string, ...params: VariadicBindParams): T | null;
|
|
189
|
+
/**
|
|
190
|
+
* Shorthand for [`prepareAsync()`](#prepareasyncsource) and [`Statement.eachSync()`](#eachsyncparams).
|
|
191
|
+
* Unlike [`Statement.eachSync()`](#eachsyncparams), this method finalizes the statement after execution.
|
|
192
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
|
|
182
193
|
* @param source A string containing the SQL query.
|
|
183
|
-
* @param params
|
|
194
|
+
* @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`BindValue`](#bindvalue) for more information about binding values.
|
|
184
195
|
*/
|
|
185
|
-
eachSync<T>(source: string, ...params: VariadicBindParams): IterableIterator<T>;
|
|
186
196
|
eachSync<T>(source: string, params: BindParams): IterableIterator<T>;
|
|
187
197
|
/**
|
|
188
|
-
*
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
*
|
|
198
|
+
* @hidden
|
|
199
|
+
*/
|
|
200
|
+
eachSync<T>(source: string, ...params: VariadicBindParams): IterableIterator<T>;
|
|
201
|
+
/**
|
|
202
|
+
* Shorthand for [`prepareAsync()`](#prepareasyncsource) and [`Statement.allSync()`](#allsyncparams).
|
|
203
|
+
* Unlike [`Statement.allSync()`](#allsyncparams), this method finalizes the statement after execution.
|
|
204
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
|
|
193
205
|
* @param source A string containing the SQL query.
|
|
194
|
-
* @param params
|
|
206
|
+
* @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`BindValue`](#bindvalue) for more information about binding values.
|
|
195
207
|
*/
|
|
196
|
-
allSync<T>(source: string, ...params: VariadicBindParams): T[];
|
|
197
208
|
allSync<T>(source: string, params: BindParams): T[];
|
|
209
|
+
/**
|
|
210
|
+
* @hidden
|
|
211
|
+
*/
|
|
212
|
+
allSync<T>(source: string, ...params: VariadicBindParams): T[];
|
|
198
213
|
}
|
|
199
214
|
/**
|
|
200
215
|
* Open a database.
|
|
201
216
|
*
|
|
202
217
|
* @param dbName The name of the database file to open.
|
|
203
218
|
* @param options Open options.
|
|
204
|
-
* @returns Database object.
|
|
205
219
|
*/
|
|
206
220
|
export declare function openDatabaseAsync(dbName: string, options?: OpenOptions): Promise<Database>;
|
|
207
221
|
/**
|
|
208
222
|
* Open a database.
|
|
209
223
|
*
|
|
210
|
-
* > **Note:** Running heavy tasks with this function can block the JavaScript thread
|
|
224
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
|
|
211
225
|
*
|
|
212
226
|
* @param dbName The name of the database file to open.
|
|
213
227
|
* @param options Open options.
|
|
214
|
-
* @returns Database object.
|
|
215
228
|
*/
|
|
216
229
|
export declare function openDatabaseSync(dbName: string, options?: OpenOptions): Database;
|
|
217
230
|
/**
|
|
@@ -223,19 +236,15 @@ export declare function deleteDatabaseAsync(dbName: string): Promise<void>;
|
|
|
223
236
|
/**
|
|
224
237
|
* Delete a database file.
|
|
225
238
|
*
|
|
226
|
-
* > **Note:** Running heavy tasks with this function can block the JavaScript thread
|
|
239
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
|
|
227
240
|
*
|
|
228
241
|
* @param dbName The name of the database file to delete.
|
|
229
242
|
*/
|
|
230
243
|
export declare function deleteDatabaseSync(dbName: string): void;
|
|
231
244
|
/**
|
|
232
|
-
*
|
|
233
|
-
* > Note: to enable this feature, you must set `enableChangeListener` to `true` when opening the database.
|
|
234
|
-
*
|
|
235
|
-
* @param listener A function that receives the `dbName`, `tableName` and `rowId` of the modified data.
|
|
236
|
-
* @returns A `Subscription` object that you can call `remove()` on when you would like to unsubscribe the listener.
|
|
245
|
+
* The event payload for the listener of [`addDatabaseChangeListener`](#sqliteadddatabasechangelistenerlistener)
|
|
237
246
|
*/
|
|
238
|
-
export
|
|
247
|
+
export type DatabaseChangeEvent = {
|
|
239
248
|
/** The database name. The value would be `main` by default and other database names if you use `ATTACH DATABASE` statement. */
|
|
240
249
|
dbName: string;
|
|
241
250
|
/** The absolute file path to the database. */
|
|
@@ -244,9 +253,18 @@ export declare function addDatabaseChangeListener(listener: (event: {
|
|
|
244
253
|
tableName: string;
|
|
245
254
|
/** The changed row ID. */
|
|
246
255
|
rowId: number;
|
|
247
|
-
}
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* Add a listener for database changes.
|
|
259
|
+
* > Note: to enable this feature, you must set [`enableChangeListener` to `true`](#openoptions) when opening the database.
|
|
260
|
+
*
|
|
261
|
+
* @param listener A function that receives the `dbFilePath`, `dbName`, `tableName` and `rowId` of the modified data.
|
|
262
|
+
* @returns A `Subscription` object that you can call `remove()` on when you would like to unsubscribe the listener.
|
|
263
|
+
*/
|
|
264
|
+
export declare function addDatabaseChangeListener(listener: (event: DatabaseChangeEvent) => void): Subscription;
|
|
248
265
|
/**
|
|
249
|
-
* A new connection specific for `transactionExclusiveAsync
|
|
266
|
+
* A new connection specific used for [`transactionExclusiveAsync`](#transactionexclusiveasynctask).
|
|
267
|
+
* @hidden not going to pull all the database methods to the document.
|
|
250
268
|
*/
|
|
251
269
|
declare class Transaction extends Database {
|
|
252
270
|
static createAsync(db: Database): Promise<Transaction>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Database.d.ts","sourceRoot":"","sources":["../../src/next/Database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG/D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEnF,OAAO,EAAE,WAAW,EAAE,CAAC;AAIvB;;GAEG;AACH,qBAAa,QAAQ;aAED,MAAM,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"Database.d.ts","sourceRoot":"","sources":["../../src/next/Database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG/D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEnF,OAAO,EAAE,WAAW,EAAE,CAAC;AAIvB;;GAEG;AACH,qBAAa,QAAQ;aAED,MAAM,EAAE,MAAM;aACd,OAAO,EAAE,WAAW;IACpC,OAAO,CAAC,QAAQ,CAAC,cAAc;gBAFf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACnB,cAAc,EAAE,cAAc;IAGjD;;OAEG;IACI,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC;IAI/C;;OAEG;IACI,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIlC;;;;;OAKG;IACI,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C;;;;OAI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,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,kBAAkB,GAAG,CAAC,EAAE;CAatE;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAKhG;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,QAAQ,CAKhF;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAEvD;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,+HAA+H;IAC/H,MAAM,EAAE,MAAM,CAAC;IAEf,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;IAEnB,sBAAsB;IACtB,SAAS,EAAE,MAAM,CAAC;IAElB,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,GAC7C,YAAY,CAEd;AAED;;;GAGG;AACH,cAAM,WAAY,SAAQ,QAAQ;WACZ,WAAW,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC;CAMpE"}
|
package/build/next/Database.js
CHANGED
|
@@ -7,9 +7,11 @@ const emitter = new EventEmitter(ExpoSQLite);
|
|
|
7
7
|
*/
|
|
8
8
|
export class Database {
|
|
9
9
|
dbName;
|
|
10
|
+
options;
|
|
10
11
|
nativeDatabase;
|
|
11
|
-
constructor(dbName, nativeDatabase) {
|
|
12
|
+
constructor(dbName, options, nativeDatabase) {
|
|
12
13
|
this.dbName = dbName;
|
|
14
|
+
this.options = options;
|
|
13
15
|
this.nativeDatabase = nativeDatabase;
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
@@ -37,7 +39,6 @@ export class Database {
|
|
|
37
39
|
* Prepare a SQL statement.
|
|
38
40
|
*
|
|
39
41
|
* @param source A string containing the SQL query.
|
|
40
|
-
* @returns A `Statement` object.
|
|
41
42
|
*/
|
|
42
43
|
async prepareAsync(source) {
|
|
43
44
|
const nativeStatement = new ExpoSQLite.NativeStatement();
|
|
@@ -130,7 +131,8 @@ export class Database {
|
|
|
130
131
|
* Execute all SQL queries in the supplied string.
|
|
131
132
|
*
|
|
132
133
|
* > **Note:** The queries are not escaped for you! Be careful when constructing your queries.
|
|
133
|
-
*
|
|
134
|
+
*
|
|
135
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
|
|
134
136
|
*
|
|
135
137
|
* @param source A string containing all the SQL queries.
|
|
136
138
|
*/
|
|
@@ -140,10 +142,9 @@ export class Database {
|
|
|
140
142
|
/**
|
|
141
143
|
* Prepare a SQL statement.
|
|
142
144
|
*
|
|
143
|
-
* > **Note:** Running heavy tasks with this function can block the JavaScript thread
|
|
145
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
|
|
144
146
|
*
|
|
145
147
|
* @param source A string containing the SQL query.
|
|
146
|
-
* @returns A `Statement` object.
|
|
147
148
|
*/
|
|
148
149
|
prepareSync(source) {
|
|
149
150
|
const nativeStatement = new ExpoSQLite.NativeStatement();
|
|
@@ -153,7 +154,7 @@ export class Database {
|
|
|
153
154
|
/**
|
|
154
155
|
* Execute a transaction and automatically commit/rollback based on the `task` result.
|
|
155
156
|
*
|
|
156
|
-
* > **Note:** Running heavy tasks with this function can block the JavaScript thread
|
|
157
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
|
|
157
158
|
*
|
|
158
159
|
* @param task An async function to execute within a transaction.
|
|
159
160
|
*/
|
|
@@ -192,14 +193,12 @@ export class Database {
|
|
|
192
193
|
}
|
|
193
194
|
async *eachAsync(source, ...params) {
|
|
194
195
|
const statement = await this.prepareAsync(source);
|
|
195
|
-
let result;
|
|
196
196
|
try {
|
|
197
|
-
|
|
197
|
+
yield* await statement.eachAsync(...params);
|
|
198
198
|
}
|
|
199
199
|
finally {
|
|
200
200
|
await statement.finalizeAsync();
|
|
201
201
|
}
|
|
202
|
-
yield* result;
|
|
203
202
|
}
|
|
204
203
|
async allAsync(source, ...params) {
|
|
205
204
|
const statement = await this.prepareAsync(source);
|
|
@@ -236,14 +235,12 @@ export class Database {
|
|
|
236
235
|
}
|
|
237
236
|
*eachSync(source, ...params) {
|
|
238
237
|
const statement = this.prepareSync(source);
|
|
239
|
-
let result;
|
|
240
238
|
try {
|
|
241
|
-
|
|
239
|
+
yield* statement.eachSync(...params);
|
|
242
240
|
}
|
|
243
241
|
finally {
|
|
244
242
|
statement.finalizeSync();
|
|
245
243
|
}
|
|
246
|
-
yield* result;
|
|
247
244
|
}
|
|
248
245
|
allSync(source, ...params) {
|
|
249
246
|
const statement = this.prepareSync(source);
|
|
@@ -262,26 +259,26 @@ export class Database {
|
|
|
262
259
|
*
|
|
263
260
|
* @param dbName The name of the database file to open.
|
|
264
261
|
* @param options Open options.
|
|
265
|
-
* @returns Database object.
|
|
266
262
|
*/
|
|
267
263
|
export async function openDatabaseAsync(dbName, options) {
|
|
268
|
-
const
|
|
264
|
+
const openOptions = options ?? {};
|
|
265
|
+
const nativeDatabase = new ExpoSQLite.NativeDatabase(dbName, openOptions);
|
|
269
266
|
await nativeDatabase.initAsync();
|
|
270
|
-
return new Database(dbName, nativeDatabase);
|
|
267
|
+
return new Database(dbName, openOptions, nativeDatabase);
|
|
271
268
|
}
|
|
272
269
|
/**
|
|
273
270
|
* Open a database.
|
|
274
271
|
*
|
|
275
|
-
* > **Note:** Running heavy tasks with this function can block the JavaScript thread
|
|
272
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
|
|
276
273
|
*
|
|
277
274
|
* @param dbName The name of the database file to open.
|
|
278
275
|
* @param options Open options.
|
|
279
|
-
* @returns Database object.
|
|
280
276
|
*/
|
|
281
277
|
export function openDatabaseSync(dbName, options) {
|
|
282
|
-
const
|
|
278
|
+
const openOptions = options ?? {};
|
|
279
|
+
const nativeDatabase = new ExpoSQLite.NativeDatabase(dbName, openOptions);
|
|
283
280
|
nativeDatabase.initSync();
|
|
284
|
-
return new Database(dbName, nativeDatabase);
|
|
281
|
+
return new Database(dbName, openOptions, nativeDatabase);
|
|
285
282
|
}
|
|
286
283
|
/**
|
|
287
284
|
* Delete a database file.
|
|
@@ -294,7 +291,7 @@ export async function deleteDatabaseAsync(dbName) {
|
|
|
294
291
|
/**
|
|
295
292
|
* Delete a database file.
|
|
296
293
|
*
|
|
297
|
-
* > **Note:** Running heavy tasks with this function can block the JavaScript thread
|
|
294
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
|
|
298
295
|
*
|
|
299
296
|
* @param dbName The name of the database file to delete.
|
|
300
297
|
*/
|
|
@@ -303,22 +300,24 @@ export function deleteDatabaseSync(dbName) {
|
|
|
303
300
|
}
|
|
304
301
|
/**
|
|
305
302
|
* Add a listener for database changes.
|
|
306
|
-
* > Note: to enable this feature, you must set `enableChangeListener` to `true` when opening the database.
|
|
303
|
+
* > Note: to enable this feature, you must set [`enableChangeListener` to `true`](#openoptions) when opening the database.
|
|
307
304
|
*
|
|
308
|
-
* @param listener A function that receives the `dbName`, `tableName` and `rowId` of the modified data.
|
|
305
|
+
* @param listener A function that receives the `dbFilePath`, `dbName`, `tableName` and `rowId` of the modified data.
|
|
309
306
|
* @returns A `Subscription` object that you can call `remove()` on when you would like to unsubscribe the listener.
|
|
310
307
|
*/
|
|
311
308
|
export function addDatabaseChangeListener(listener) {
|
|
312
309
|
return emitter.addListener('onDatabaseChange', listener);
|
|
313
310
|
}
|
|
314
311
|
/**
|
|
315
|
-
* A new connection specific for `transactionExclusiveAsync
|
|
312
|
+
* A new connection specific used for [`transactionExclusiveAsync`](#transactionexclusiveasynctask).
|
|
313
|
+
* @hidden not going to pull all the database methods to the document.
|
|
316
314
|
*/
|
|
317
315
|
class Transaction extends Database {
|
|
318
316
|
static async createAsync(db) {
|
|
319
|
-
const
|
|
317
|
+
const options = { ...db.options, useNewConnection: true };
|
|
318
|
+
const nativeDatabase = new ExpoSQLite.NativeDatabase(db.dbName, options);
|
|
320
319
|
await nativeDatabase.initAsync();
|
|
321
|
-
return new Transaction(db.dbName, nativeDatabase);
|
|
320
|
+
return new Transaction(db.dbName, options, nativeDatabase);
|
|
322
321
|
}
|
|
323
322
|
}
|
|
324
323
|
//# sourceMappingURL=Database.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Database.js","sourceRoot":"","sources":["../../src/next/Database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,MAAM,mBAAmB,CAAC;AAE/D,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAyB,SAAS,EAAsB,MAAM,aAAa,CAAC;AAInF,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;AAE7C;;GAEG;AACH,MAAM,OAAO,QAAQ;IAED;IACC;IAFnB,YACkB,MAAc,EACb,cAA8B;QAD/B,WAAM,GAAN,MAAM,CAAQ;QACb,mBAAc,GAAd,cAAc,CAAgB;IAC9C,CAAC;IAEJ;;OAEG;IACI,oBAAoB;QACzB,OAAO,IAAI,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;IACpD,CAAC;IAED;;OAEG;IACI,UAAU;QACf,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACI,SAAS,CAAC,MAAc;QAC7B,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,YAAY,CAAC,MAAc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,MAAM,cAAc,GAAG,IAAI,UAAU,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;IAC5E,cAAc,CAAC,QAAQ,EAAE,CAAC;IAC1B,OAAO,IAAI,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAC9C,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,MAAc;IACtD,OAAO,MAAM,UAAU,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,OAAO,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAYU;IAEV,OAAO,OAAO,CAAC,WAAW,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;AAC3D,CAAC;AAED;;GAEG;AACH,MAAM,WAAY,SAAQ,QAAQ;IACzB,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,EAAY;QAC1C,MAAM,cAAc,GAAG,IAAI,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5F,MAAM,cAAc,CAAC,SAAS,EAAE,CAAC;QACjC,OAAO,IAAI,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACpD,CAAC;CACF","sourcesContent":["import { EventEmitter, Subscription } from 'expo-modules-core';\n\nimport ExpoSQLite from './ExpoSQLiteNext';\nimport { NativeDatabase, OpenOptions } from './NativeDatabase';\nimport { BindParams, RunResult, Statement, VariadicBindParams } from './Statement';\n\nexport { OpenOptions };\n\nconst emitter = new EventEmitter(ExpoSQLite);\n\n/**\n * A SQLite database.\n */\nexport class Database {\n constructor(\n public readonly dbName: string,\n private readonly nativeDatabase: NativeDatabase\n ) {}\n\n /**\n * Asynchronous call to return whether the database is currently in a transaction.\n */\n public isInTransactionAsync(): Promise<boolean> {\n return this.nativeDatabase.isInTransactionAsync();\n }\n\n /**\n * Close the database.\n */\n public closeAsync(): Promise<void> {\n return this.nativeDatabase.closeAsync();\n }\n\n /**\n * Execute all SQL queries in the supplied string.\n * > Note: The queries are not escaped for you! Be careful when constructing your queries.\n *\n * @param source A string containing all the SQL queries.\n */\n public execAsync(source: string): Promise<void> {\n return this.nativeDatabase.execAsync(source);\n }\n\n /**\n * Prepare a SQL statement.\n *\n * @param source A string containing the SQL query.\n * @returns A `Statement` object.\n */\n public async prepareAsync(source: string): Promise<Statement> {\n const nativeStatement = new ExpoSQLite.NativeStatement();\n await this.nativeDatabase.prepareAsync(nativeStatement, source);\n return new Statement(this.nativeDatabase, nativeStatement);\n }\n\n /**\n * Execute a transaction and automatically commit/rollback based on the `task` result.\n *\n * > **Note:** This transaction is not exclusive and can be interrupted by other async queries.\n * @example\n * ```ts\n * db.transactionAsync(async () => {\n * await db.execAsync('UPDATE test SET name = \"aaa\"');\n *\n * //\n * // We cannot control the order of async/await order, so order of execution is not guaranteed.\n * // The following UPDATE query out of transaction may be executed here and break the expectation.\n * //\n *\n * const result = await db.getAsync<{ name: string }>('SELECT name FROM Users');\n * expect(result?.name).toBe('aaa');\n * });\n * db.execAsync('UPDATE test SET name = \"bbb\"');\n * ```\n * If you worry about the order of execution, use `transactionExclusiveAsync` instead.\n *\n * @param task An async function to execute within a transaction.\n */\n public async transactionAsync(task: () => Promise<void>): Promise<void> {\n try {\n await this.execAsync('BEGIN');\n await task();\n await this.execAsync('COMMIT');\n } catch (e) {\n await this.execAsync('ROLLBACK');\n throw e;\n }\n }\n\n /**\n * Execute a transaction and automatically commit/rollback based on the `task` result.\n *\n * The transaction may be exclusive.\n * As long as the transaction is converted into a write transaction,\n * the other async write queries will abort with `database is locked` error.\n *\n * @param task An async function to execute within a transaction. Any queries inside the transaction must be executed on the `txn` object.\n * The `txn` object has the same interfaces as the `Database` object. You can use `txn` like a `Database` object.\n *\n * @example\n * ```ts\n * db.transactionExclusiveAsync(async (txn) => {\n * await txn.execAsync('UPDATE test SET name = \"aaa\"');\n * });\n * ```\n */\n public async transactionExclusiveAsync(task: (txn: Transaction) => Promise<void>): Promise<void> {\n const transaction = await Transaction.createAsync(this);\n let error;\n try {\n await transaction.execAsync('BEGIN');\n await task(transaction);\n await transaction.execAsync('COMMIT');\n } catch (e) {\n await transaction.execAsync('ROLLBACK');\n error = e;\n } finally {\n await transaction.closeAsync();\n }\n if (error) {\n throw error;\n }\n }\n\n /**\n * Synchronous call to return whether the database is currently in a transaction.\n */\n public isInTransactionSync(): boolean {\n return this.nativeDatabase.isInTransactionSync();\n }\n\n /**\n * Close the database.\n */\n public closeSync(): void {\n return this.nativeDatabase.closeSync();\n }\n\n /**\n * Execute all SQL queries in the supplied string.\n *\n * > **Note:** The queries are not escaped for you! Be careful when constructing your queries.\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread, affecting performance.\n *\n * @param source A string containing all the SQL queries.\n */\n public execSync(source: string): void {\n return this.nativeDatabase.execSync(source);\n }\n\n /**\n * Prepare a SQL statement.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread, affecting performance.\n *\n * @param source A string containing the SQL query.\n * @returns A `Statement` object.\n */\n public prepareSync(source: string): Statement {\n const nativeStatement = new ExpoSQLite.NativeStatement();\n this.nativeDatabase.prepareSync(nativeStatement, source);\n return new Statement(this.nativeDatabase, nativeStatement);\n }\n\n /**\n * Execute a transaction and automatically commit/rollback based on the `task` result.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread, affecting performance.\n *\n * @param task An async function to execute within a transaction.\n */\n public transactionSync(task: () => void): void {\n try {\n this.execSync('BEGIN');\n task();\n this.execSync('COMMIT');\n } catch (e) {\n this.execSync('ROLLBACK');\n throw e;\n }\n }\n\n //#region Statement API shorthands\n\n /**\n * Shorthand for `prepareAsync` and `Statement.runAsync`.\n * Unlike `Statement.runAsync`, this method finalizes the statement after execution.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread, affecting performance.\n *\n * @param source A string containing the SQL query.\n * @param params Parameters to bind to the query.\n */\n public runAsync(source: string, ...params: VariadicBindParams): Promise<RunResult>;\n public runAsync(source: string, params: BindParams): Promise<RunResult>;\n public async runAsync(source: string, ...params: any[]): Promise<RunResult> {\n const statement = await this.prepareAsync(source);\n let result;\n try {\n result = await statement.runAsync(...params);\n } finally {\n await statement.finalizeAsync();\n }\n return result;\n }\n\n /**\n * Shorthand for `prepareAsync` and `Statement.getAsync`.\n * Unlike `Statement.getAsync`, this method finalizes the statement after execution.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread, affecting performance.\n *\n * @param source A string containing the SQL query.\n * @param params Parameters to bind to the query.\n */\n public getAsync<T>(source: string, ...params: VariadicBindParams): Promise<T | null>;\n public getAsync<T>(source: string, params: BindParams): Promise<T | null>;\n public async getAsync<T>(source: string, ...params: any[]): Promise<T | null> {\n const statement = await this.prepareAsync(source);\n let result;\n try {\n result = await statement.getAsync<T>(...params);\n } finally {\n await statement.finalizeAsync();\n }\n return result;\n }\n\n /**\n * Shorthand for `prepareAsync` and `Statement.eachAsync`.\n * Unlike `Statement.eachAsync`, this method finalizes the statement after execution.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread, affecting performance.\n *\n * @param source A string containing the SQL query.\n * @param params Parameters to bind to the query.\n */\n public eachAsync<T>(source: string, ...params: VariadicBindParams): AsyncIterableIterator<T>;\n public eachAsync<T>(source: string, params: BindParams): AsyncIterableIterator<T>;\n public async *eachAsync<T>(source: string, ...params: any[]): AsyncIterableIterator<T> {\n const statement = await this.prepareAsync(source);\n let result;\n try {\n result = await statement.eachAsync<T>(...params);\n } finally {\n await statement.finalizeAsync();\n }\n yield* result;\n }\n\n /**\n * Shorthand for `prepareAsync` and `Statement.allAsync`.\n * Unlike `Statement.allAsync`, this method finalizes the statement after execution.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread, affecting performance.\n *\n * @param source A string containing the SQL query.\n * @param params Parameters to bind to the query.\n */\n public allAsync<T>(source: string, ...params: VariadicBindParams): Promise<T[]>;\n public allAsync<T>(source: string, params: BindParams): Promise<T[]>;\n public async allAsync<T>(source: string, ...params: any[]): Promise<T[]> {\n const statement = await this.prepareAsync(source);\n let result;\n try {\n result = await statement.allAsync<T>(...params);\n } finally {\n await statement.finalizeAsync();\n }\n return result;\n }\n\n /**\n * Shorthand for `prepareSync` and `Statement.runSync`.\n * Unlike `Statement.runSync`, this method finalizes the statement after execution.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread, affecting performance.\n *\n * @param source A string containing the SQL query.\n * @param params Parameters to bind to the query.\n */\n public runSync(source: string, ...params: VariadicBindParams): RunResult;\n public runSync(source: string, params: BindParams): RunResult;\n public runSync(source: string, ...params: any[]): RunResult {\n const statement = this.prepareSync(source);\n let result;\n try {\n result = statement.runSync(...params);\n } finally {\n statement.finalizeSync();\n }\n return result;\n }\n\n /**\n * Shorthand for `prepareSync` and `Statement.getSync`.\n * Unlike `Statement.getSync`, this method finalizes the statement after execution.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread, affecting performance.\n *\n * @param source A string containing the SQL query.\n * @param params Parameters to bind to the query.\n */\n public getSync<T>(source: string, ...params: VariadicBindParams): T | null;\n public getSync<T>(source: string, params: BindParams): T | null;\n public getSync<T>(source: string, ...params: any[]): T | null {\n const statement = this.prepareSync(source);\n let result;\n try {\n result = statement.getSync<T>(...params);\n } finally {\n statement.finalizeSync();\n }\n return result;\n }\n\n /**\n * Shorthand for `prepareSync` and `Statement.eachSync`.\n * Unlike `Statement.eachSync`, this method finalizes the statement after execution.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread, affecting performance.\n *\n * @param source A string containing the SQL query.\n * @param params Parameters to bind to the query.\n */\n public eachSync<T>(source: string, ...params: VariadicBindParams): IterableIterator<T>;\n public eachSync<T>(source: string, params: BindParams): IterableIterator<T>;\n public *eachSync<T>(source: string, ...params: any[]): IterableIterator<T> {\n const statement = this.prepareSync(source);\n let result;\n try {\n result = statement.eachSync<T>(...params);\n } finally {\n statement.finalizeSync();\n }\n yield* result;\n }\n\n /**\n * Shorthand for `prepareSync` and `Statement.allSync`.\n * Unlike `Statement.allSync`, this method finalizes the statement after execution.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread, affecting performance.\n *\n * @param source A string containing the SQL query.\n * @param params Parameters to bind to the query.\n */\n public allSync<T>(source: string, ...params: VariadicBindParams): T[];\n public allSync<T>(source: string, params: BindParams): T[];\n public allSync<T>(source: string, ...params: any[]): T[] {\n const statement = this.prepareSync(source);\n let result;\n try {\n result = statement.allSync<T>(...params);\n } finally {\n statement.finalizeSync();\n }\n return result;\n }\n\n //#endregion\n}\n\n/**\n * Open a database.\n *\n * @param dbName The name of the database file to open.\n * @param options Open options.\n * @returns Database object.\n */\nexport async function openDatabaseAsync(dbName: string, options?: OpenOptions): Promise<Database> {\n const nativeDatabase = new ExpoSQLite.NativeDatabase(dbName, options ?? {});\n await nativeDatabase.initAsync();\n return new Database(dbName, nativeDatabase);\n}\n\n/**\n * Open a database.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread, affecting performance.\n *\n * @param dbName The name of the database file to open.\n * @param options Open options.\n * @returns Database object.\n */\nexport function openDatabaseSync(dbName: string, options?: OpenOptions): Database {\n const nativeDatabase = new ExpoSQLite.NativeDatabase(dbName, options ?? {});\n nativeDatabase.initSync();\n return new Database(dbName, nativeDatabase);\n}\n\n/**\n * Delete a database file.\n *\n * @param dbName The name of the database file to delete.\n */\nexport async function deleteDatabaseAsync(dbName: string): Promise<void> {\n return await ExpoSQLite.deleteDatabaseAsync(dbName);\n}\n\n/**\n * Delete a database file.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread, affecting performance.\n *\n * @param dbName The name of the database file to delete.\n */\nexport function deleteDatabaseSync(dbName: string): void {\n return ExpoSQLite.deleteDatabaseSync(dbName);\n}\n\n/**\n * Add a listener for database changes.\n * > Note: to enable this feature, you must set `enableChangeListener` to `true` when opening the database.\n *\n * @param listener A function that receives the `dbName`, `tableName` and `rowId` of the modified data.\n * @returns A `Subscription` object that you can call `remove()` on when you would like to unsubscribe the listener.\n */\nexport function addDatabaseChangeListener(\n listener: (event: {\n /** The database name. The value would be `main` by default and other database names if you use `ATTACH DATABASE` statement. */\n dbName: string;\n\n /** The absolute file path to the database. */\n dbFilePath: string;\n\n /** The table name. */\n tableName: string;\n\n /** The changed row ID. */\n rowId: number;\n }) => void\n): Subscription {\n return emitter.addListener('onDatabaseChange', listener);\n}\n\n/**\n * A new connection specific for `transactionExclusiveAsync`.\n */\nclass Transaction extends Database {\n public static async createAsync(db: Database): Promise<Transaction> {\n const nativeDatabase = new ExpoSQLite.NativeDatabase(db.dbName, { useNewConnection: true });\n await nativeDatabase.initAsync();\n return new Transaction(db.dbName, nativeDatabase);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Database.js","sourceRoot":"","sources":["../../src/next/Database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,MAAM,mBAAmB,CAAC;AAE/D,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAyB,SAAS,EAAsB,MAAM,aAAa,CAAC;AAInF,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;AAE7C;;GAEG;AACH,MAAM,OAAO,QAAQ;IAED;IACA;IACC;IAHnB,YACkB,MAAc,EACd,OAAoB,EACnB,cAA8B;QAF/B,WAAM,GAAN,MAAM,CAAQ;QACd,YAAO,GAAP,OAAO,CAAa;QACnB,mBAAc,GAAd,cAAc,CAAgB;IAC9C,CAAC;IAEJ;;OAEG;IACI,oBAAoB;QACzB,OAAO,IAAI,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;IACpD,CAAC;IAED;;OAEG;IACI,UAAU;QACf,OAAO,IAAI,CAAC,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C;CACF","sourcesContent":["import { EventEmitter, Subscription } from 'expo-modules-core';\n\nimport ExpoSQLite from './ExpoSQLiteNext';\nimport { NativeDatabase, OpenOptions } from './NativeDatabase';\nimport { BindParams, RunResult, Statement, VariadicBindParams } from './Statement';\n\nexport { OpenOptions };\n\nconst emitter = new EventEmitter(ExpoSQLite);\n\n/**\n * A SQLite database.\n */\nexport class Database {\n constructor(\n public readonly dbName: string,\n public readonly options: OpenOptions,\n private readonly nativeDatabase: NativeDatabase\n ) {}\n\n /**\n * Asynchronous call to return whether the database is currently in a transaction.\n */\n public isInTransactionAsync(): Promise<boolean> {\n return this.nativeDatabase.isInTransactionAsync();\n }\n\n /**\n * Close the database.\n */\n public closeAsync(): Promise<void> {\n return this.nativeDatabase.closeAsync();\n }\n\n /**\n * Execute all SQL queries in the supplied string.\n * > Note: The queries are not escaped for you! Be careful when constructing your queries.\n *\n * @param source A string containing all the SQL queries.\n */\n public execAsync(source: string): Promise<void> {\n return this.nativeDatabase.execAsync(source);\n }\n\n /**\n * Prepare a SQL statement.\n *\n * @param source A string containing the SQL query.\n */\n public async prepareAsync(source: string): Promise<Statement> {\n const nativeStatement = new ExpoSQLite.NativeStatement();\n await this.nativeDatabase.prepareAsync(nativeStatement, source);\n return new Statement(this.nativeDatabase, nativeStatement);\n }\n\n /**\n * Execute a transaction and automatically commit/rollback based on the `task` result.\n *\n * > **Note:** This transaction is not exclusive and can be interrupted by other async queries.\n * @example\n * ```ts\n * db.transactionAsync(async () => {\n * await db.execAsync('UPDATE test SET name = \"aaa\"');\n *\n * //\n * // We cannot control the order of async/await order, so order of execution is not guaranteed.\n * // The following UPDATE query out of transaction may be executed here and break the expectation.\n * //\n *\n * const result = await db.getAsync<{ name: string }>('SELECT name FROM Users');\n * expect(result?.name).toBe('aaa');\n * });\n * db.execAsync('UPDATE test SET name = \"bbb\"');\n * ```\n * If you worry about the order of execution, use `transactionExclusiveAsync` instead.\n *\n * @param task An async function to execute within a transaction.\n */\n public async transactionAsync(task: () => Promise<void>): Promise<void> {\n try {\n await this.execAsync('BEGIN');\n await task();\n await this.execAsync('COMMIT');\n } catch (e) {\n await this.execAsync('ROLLBACK');\n throw e;\n }\n }\n\n /**\n * Execute a transaction and automatically commit/rollback based on the `task` result.\n *\n * The transaction may be exclusive.\n * As long as the transaction is converted into a write transaction,\n * the other async write queries will abort with `database is locked` error.\n *\n * @param task An async function to execute within a transaction. Any queries inside the transaction must be executed on the `txn` object.\n * The `txn` object has the same interfaces as the `Database` object. You can use `txn` like a `Database` object.\n *\n * @example\n * ```ts\n * db.transactionExclusiveAsync(async (txn) => {\n * await txn.execAsync('UPDATE test SET name = \"aaa\"');\n * });\n * ```\n */\n public async transactionExclusiveAsync(task: (txn: Transaction) => Promise<void>): Promise<void> {\n const transaction = await Transaction.createAsync(this);\n let error;\n try {\n await transaction.execAsync('BEGIN');\n await task(transaction);\n await transaction.execAsync('COMMIT');\n } catch (e) {\n await transaction.execAsync('ROLLBACK');\n error = e;\n } finally {\n await transaction.closeAsync();\n }\n if (error) {\n throw error;\n }\n }\n\n /**\n * Synchronous call to return whether the database is currently in a transaction.\n */\n public isInTransactionSync(): boolean {\n return this.nativeDatabase.isInTransactionSync();\n }\n\n /**\n * Close the database.\n */\n public closeSync(): void {\n return this.nativeDatabase.closeSync();\n }\n\n /**\n * Execute all SQL queries in the supplied string.\n *\n * > **Note:** The queries are not escaped for you! Be careful when constructing your queries.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param source A string containing all the SQL queries.\n */\n public execSync(source: string): void {\n return this.nativeDatabase.execSync(source);\n }\n\n /**\n * Prepare a SQL statement.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param source A string containing the SQL query.\n */\n public prepareSync(source: string): Statement {\n const nativeStatement = new ExpoSQLite.NativeStatement();\n this.nativeDatabase.prepareSync(nativeStatement, source);\n return new Statement(this.nativeDatabase, nativeStatement);\n }\n\n /**\n * Execute a transaction and automatically commit/rollback based on the `task` result.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param task An async function to execute within a transaction.\n */\n public transactionSync(task: () => void): void {\n try {\n this.execSync('BEGIN');\n task();\n this.execSync('COMMIT');\n } catch (e) {\n this.execSync('ROLLBACK');\n throw e;\n }\n }\n\n //#region Statement API shorthands\n\n /**\n * Shorthand for [`prepareAsync()`](#prepareasyncsource) and [`Statement.runAsync()`](#runasyncparams).\n * Unlike [`Statement.runAsync()`](#runasyncparams), this method finalizes the statement after execution.\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`BindValue`](#bindvalue) for more information about binding values.\n */\n public runAsync(source: string, params: BindParams): Promise<RunResult>;\n\n /**\n * @hidden\n */\n public runAsync(source: string, ...params: VariadicBindParams): Promise<RunResult>;\n public async runAsync(source: string, ...params: any[]): Promise<RunResult> {\n const statement = await this.prepareAsync(source);\n let result;\n try {\n result = await statement.runAsync(...params);\n } finally {\n await statement.finalizeAsync();\n }\n return result;\n }\n\n /**\n * Shorthand for [`prepareAsync()`](#prepareasyncsource) and [`Statement.getAsync()`](#getasyncparams).\n * Unlike [`Statement.getAsync()`](#getasyncparams), this method finalizes the statement after execution.\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`BindValue`](#bindvalue) for more information about binding values.\n */\n public getAsync<T>(source: string, params: BindParams): Promise<T | null>;\n /**\n * @hidden\n */\n public getAsync<T>(source: string, ...params: VariadicBindParams): Promise<T | null>;\n public async getAsync<T>(source: string, ...params: any[]): Promise<T | null> {\n const statement = await this.prepareAsync(source);\n let result;\n try {\n result = await statement.getAsync<T>(...params);\n } finally {\n await statement.finalizeAsync();\n }\n return result;\n }\n\n /**\n * Shorthand for [`prepareAsync()`](#prepareasyncsource) and [`Statement.eachAsync()`](#eachasyncparams).\n * Unlike [`Statement.eachAsync()`](#eachasyncparams), this method finalizes the statement after execution.\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`BindValue`](#bindvalue) for more information about binding values.\n */\n public eachAsync<T>(source: string, params: BindParams): AsyncIterableIterator<T>;\n /**\n * @hidden\n */\n public eachAsync<T>(source: string, ...params: VariadicBindParams): AsyncIterableIterator<T>;\n public async *eachAsync<T>(source: string, ...params: any[]): AsyncIterableIterator<T> {\n const statement = await this.prepareAsync(source);\n try {\n yield* await statement.eachAsync<T>(...params);\n } finally {\n await statement.finalizeAsync();\n }\n }\n\n /**\n * Shorthand for [`prepareAsync()`](#prepareasyncsource) and [`Statement.allAsync()`](#allasyncparams).\n * Unlike [`Statement.allAsync()`](#allasyncparams), this method finalizes the statement after execution.\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`BindValue`](#bindvalue) for more information about binding values.\n * @example\n * ```ts\n * // For unnamed parameters, you pass values in an array.\n * db.allAsync('SELECT * FROM test WHERE intValue = ? AND name = ?', [1, 'Hello']);\n *\n * // For unnamed parameters, you pass values in variadic arguments.\n * db.allAsync('SELECT * FROM test WHERE intValue = ? AND name = ?', 1, 'Hello');\n *\n * // For named parameters, you should pass values in object.\n * db.allAsync('SELECT * FROM test WHERE intValue = $intValue AND name = $name', { $intValue: 1, $name: 'Hello' });\n * ```\n */\n public allAsync<T>(source: string, params: BindParams): Promise<T[]>;\n /**\n * @hidden\n */\n public allAsync<T>(source: string, ...params: VariadicBindParams): Promise<T[]>;\n public async allAsync<T>(source: string, ...params: any[]): Promise<T[]> {\n const statement = await this.prepareAsync(source);\n let result;\n try {\n result = await statement.allAsync<T>(...params);\n } finally {\n await statement.finalizeAsync();\n }\n return result;\n }\n\n /**\n * Shorthand for [`prepareAsync()`](#prepareasyncsource) and [`Statement.runSync()`](#runsyncparams).\n * Unlike [`Statement.runSync()`](#runsyncparams), this method finalizes the statement after execution.\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`BindValue`](#bindvalue) for more information about binding values.\n */\n public runSync(source: string, params: BindParams): RunResult;\n /**\n * @hidden\n */\n public runSync(source: string, ...params: VariadicBindParams): RunResult;\n public runSync(source: string, ...params: any[]): RunResult {\n const statement = this.prepareSync(source);\n let result;\n try {\n result = statement.runSync(...params);\n } finally {\n statement.finalizeSync();\n }\n return result;\n }\n\n /**\n * Shorthand for [`prepareAsync()`](#prepareasyncsource) and [`Statement.getSync()`](#getsyncparams).\n * Unlike [`Statement.getSync()`](#getsyncparams), this method finalizes the statement after execution.\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`BindValue`](#bindvalue) for more information about binding values.\n */\n public getSync<T>(source: string, params: BindParams): T | null;\n /**\n * @hidden\n */\n public getSync<T>(source: string, ...params: VariadicBindParams): T | null;\n public getSync<T>(source: string, ...params: any[]): T | null {\n const statement = this.prepareSync(source);\n let result;\n try {\n result = statement.getSync<T>(...params);\n } finally {\n statement.finalizeSync();\n }\n return result;\n }\n\n /**\n * Shorthand for [`prepareAsync()`](#prepareasyncsource) and [`Statement.eachSync()`](#eachsyncparams).\n * Unlike [`Statement.eachSync()`](#eachsyncparams), this method finalizes the statement after execution.\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`BindValue`](#bindvalue) for more information about binding values.\n */\n public eachSync<T>(source: string, params: BindParams): IterableIterator<T>;\n /**\n * @hidden\n */\n public eachSync<T>(source: string, ...params: VariadicBindParams): IterableIterator<T>;\n public *eachSync<T>(source: string, ...params: any[]): IterableIterator<T> {\n const statement = this.prepareSync(source);\n try {\n yield* statement.eachSync<T>(...params);\n } finally {\n statement.finalizeSync();\n }\n }\n\n /**\n * Shorthand for [`prepareAsync()`](#prepareasyncsource) and [`Statement.allSync()`](#allsyncparams).\n * Unlike [`Statement.allSync()`](#allsyncparams), this method finalizes the statement after execution.\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`BindValue`](#bindvalue) for more information about binding values.\n */\n public allSync<T>(source: string, params: BindParams): T[];\n /**\n * @hidden\n */\n public allSync<T>(source: string, ...params: VariadicBindParams): T[];\n public allSync<T>(source: string, ...params: any[]): T[] {\n const statement = this.prepareSync(source);\n let result;\n try {\n result = statement.allSync<T>(...params);\n } finally {\n statement.finalizeSync();\n }\n return result;\n }\n\n //#endregion\n}\n\n/**\n * Open a database.\n *\n * @param dbName The name of the database file to open.\n * @param options Open options.\n */\nexport async function openDatabaseAsync(dbName: string, options?: OpenOptions): Promise<Database> {\n const openOptions = options ?? {};\n const nativeDatabase = new ExpoSQLite.NativeDatabase(dbName, openOptions);\n await nativeDatabase.initAsync();\n return new Database(dbName, openOptions, nativeDatabase);\n}\n\n/**\n * Open a database.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param dbName The name of the database file to open.\n * @param options Open options.\n */\nexport function openDatabaseSync(dbName: string, options?: OpenOptions): Database {\n const openOptions = options ?? {};\n const nativeDatabase = new ExpoSQLite.NativeDatabase(dbName, openOptions);\n nativeDatabase.initSync();\n return new Database(dbName, openOptions, nativeDatabase);\n}\n\n/**\n * Delete a database file.\n *\n * @param dbName The name of the database file to delete.\n */\nexport async function deleteDatabaseAsync(dbName: string): Promise<void> {\n return await ExpoSQLite.deleteDatabaseAsync(dbName);\n}\n\n/**\n * Delete a database file.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param dbName The name of the database file to delete.\n */\nexport function deleteDatabaseSync(dbName: string): void {\n return ExpoSQLite.deleteDatabaseSync(dbName);\n}\n\n/**\n * The event payload for the listener of [`addDatabaseChangeListener`](#sqliteadddatabasechangelistenerlistener)\n */\nexport type DatabaseChangeEvent = {\n /** The database name. The value would be `main` by default and other database names if you use `ATTACH DATABASE` statement. */\n dbName: string;\n\n /** The absolute file path to the database. */\n dbFilePath: string;\n\n /** The table name. */\n tableName: string;\n\n /** The changed row ID. */\n rowId: number;\n};\n\n/**\n * Add a listener for database changes.\n * > Note: to enable this feature, you must set [`enableChangeListener` to `true`](#openoptions) when opening the database.\n *\n * @param listener A function that receives the `dbFilePath`, `dbName`, `tableName` and `rowId` of the modified data.\n * @returns A `Subscription` object that you can call `remove()` on when you would like to unsubscribe the listener.\n */\nexport function addDatabaseChangeListener(\n listener: (event: DatabaseChangeEvent) => void\n): Subscription {\n return emitter.addListener('onDatabaseChange', listener);\n}\n\n/**\n * A new connection specific used for [`transactionExclusiveAsync`](#transactionexclusiveasynctask).\n * @hidden not going to pull all the database methods to the document.\n */\nclass Transaction extends Database {\n public static async createAsync(db: Database): Promise<Transaction> {\n const options = { ...db.options, useNewConnection: true };\n const nativeDatabase = new ExpoSQLite.NativeDatabase(db.dbName, options);\n await nativeDatabase.initAsync();\n return new Transaction(db.dbName, options, nativeDatabase);\n }\n}\n"]}
|
|
@@ -25,7 +25,7 @@ export interface OpenOptions {
|
|
|
25
25
|
*/
|
|
26
26
|
enableCRSQLite?: boolean;
|
|
27
27
|
/**
|
|
28
|
-
* Whether to call the `sqlite3_update_hook` function and enable the `onDatabaseChange` events.
|
|
28
|
+
* Whether to call the [`sqlite3_update_hook`](https://www.sqlite.org/c3ref/update_hook.html) function and enable the `onDatabaseChange` events. You can later subscribe to the change events by [`addDatabaseChangeListener`](#sqliteadddatabasechangelistenerlistener).
|
|
29
29
|
* @default false
|
|
30
30
|
*/
|
|
31
31
|
enableChangeListener?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeDatabase.js","sourceRoot":"","sources":["../../src/next/NativeDatabase.ts"],"names":[],"mappings":"","sourcesContent":["import { NativeStatement } from './NativeStatement';\n\n/**\n * A class that represents an instance of the SQLite database.\n */\nexport declare class NativeDatabase {\n constructor(dbName: string, options?: OpenOptions);\n\n //#region Asynchronous API\n\n public initAsync(): Promise<void>;\n public isInTransactionAsync(): Promise<boolean>;\n public closeAsync(): Promise<void>;\n public execAsync(source: string): Promise<void>;\n public prepareAsync(nativeStatement: NativeStatement, source: string): Promise<NativeStatement>;\n\n //#endregion\n\n //#region Synchronous API\n\n public initSync(): void;\n public isInTransactionSync(): boolean;\n public closeSync(): void;\n public execSync(source: string): void;\n public prepareSync(nativeStatement: NativeStatement, source: string): NativeStatement;\n\n //#endregion\n}\n\n/**\n * Options for opening a database.\n */\nexport interface OpenOptions {\n /**\n * Whether to enable the CR-SQLite extension.\n * @default false\n */\n enableCRSQLite?: boolean;\n\n /**\n * Whether to call the `sqlite3_update_hook` function and enable the `onDatabaseChange` events.\n * @default false\n */\n enableChangeListener?: boolean;\n\n /**\n * Whether to create new connection even if connection with the same database name exists in cache.\n * @default false\n */\n useNewConnection?: boolean;\n\n /**\n * Finalized unclosed statements automatically when the database is closed.\n * @default true\n * @hidden\n */\n finalizeUnusedStatementsBeforeClosing?: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NativeDatabase.js","sourceRoot":"","sources":["../../src/next/NativeDatabase.ts"],"names":[],"mappings":"","sourcesContent":["import { NativeStatement } from './NativeStatement';\n\n/**\n * A class that represents an instance of the SQLite database.\n */\nexport declare class NativeDatabase {\n constructor(dbName: string, options?: OpenOptions);\n\n //#region Asynchronous API\n\n public initAsync(): Promise<void>;\n public isInTransactionAsync(): Promise<boolean>;\n public closeAsync(): Promise<void>;\n public execAsync(source: string): Promise<void>;\n public prepareAsync(nativeStatement: NativeStatement, source: string): Promise<NativeStatement>;\n\n //#endregion\n\n //#region Synchronous API\n\n public initSync(): void;\n public isInTransactionSync(): boolean;\n public closeSync(): void;\n public execSync(source: string): void;\n public prepareSync(nativeStatement: NativeStatement, source: string): NativeStatement;\n\n //#endregion\n}\n\n/**\n * Options for opening a database.\n */\nexport interface OpenOptions {\n /**\n * Whether to enable the CR-SQLite extension.\n * @default false\n */\n enableCRSQLite?: boolean;\n\n /**\n * Whether to call the [`sqlite3_update_hook`](https://www.sqlite.org/c3ref/update_hook.html) function and enable the `onDatabaseChange` events. You can later subscribe to the change events by [`addDatabaseChangeListener`](#sqliteadddatabasechangelistenerlistener).\n * @default false\n */\n enableChangeListener?: boolean;\n\n /**\n * Whether to create new connection even if connection with the same database name exists in cache.\n * @default false\n */\n useNewConnection?: boolean;\n\n /**\n * Finalized unclosed statements automatically when the database is closed.\n * @default true\n * @hidden\n */\n finalizeUnusedStatementsBeforeClosing?: boolean;\n}\n"]}
|