@symbiote-native/sqlite 0.1.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/LICENSE +21 -0
- package/README.md +283 -0
- package/build/angular/index.d.ts +2 -0
- package/build/angular/index.js +2 -0
- package/build/angular/sqlite.service.d.ts +41 -0
- package/build/angular/sqlite.service.js +127 -0
- package/build/core/index.d.ts +10 -0
- package/build/core/index.js +6 -0
- package/build/core/native-database.d.ts +65 -0
- package/build/core/native-database.js +13 -0
- package/build/core/native-module.d.ts +25 -0
- package/build/core/native-module.js +17 -0
- package/build/core/native-session.d.ts +20 -0
- package/build/core/native-session.js +1 -0
- package/build/core/native-statement.d.ts +45 -0
- package/build/core/native-statement.js +6 -0
- package/build/core/param-utils.d.ts +28 -0
- package/build/core/param-utils.js +126 -0
- package/build/core/path-utils.d.ts +6 -0
- package/build/core/path-utils.js +29 -0
- package/build/core/query-utils.d.ts +17 -0
- package/build/core/query-utils.js +37 -0
- package/build/core/sqlite-database.d.ts +246 -0
- package/build/core/sqlite-database.js +427 -0
- package/build/core/sqlite-session.d.ts +84 -0
- package/build/core/sqlite-session.js +121 -0
- package/build/core/sqlite-statement.d.ts +96 -0
- package/build/core/sqlite-statement.js +321 -0
- package/build/core/sqlite-tagged-query.d.ts +73 -0
- package/build/core/sqlite-tagged-query.js +119 -0
- package/build/core/storage.d.ts +107 -0
- package/build/core/storage.js +382 -0
- package/build/core/types.d.ts +30 -0
- package/build/core/types.js +1 -0
- package/build/react/index.d.ts +2 -0
- package/build/react/index.js +2 -0
- package/build/react/sqlite-context.d.ts +25 -0
- package/build/react/sqlite-context.js +129 -0
- package/build/solid/index.d.ts +2 -0
- package/build/solid/index.js +2 -0
- package/build/solid/sqlite-context.d.ts +23 -0
- package/build/solid/sqlite-context.js +106 -0
- package/build/svelte/SQLiteProvider.svelte +88 -0
- package/build/svelte/SQLiteProvider.svelte.d.ts +13 -0
- package/build/svelte/index.d.ts +3 -0
- package/build/svelte/index.js +5 -0
- package/build/svelte/sqlite-context.d.ts +11 -0
- package/build/svelte/sqlite-context.js +23 -0
- package/build/vue/index.d.ts +2 -0
- package/build/vue/index.js +2 -0
- package/build/vue/sqlite-context.d.ts +21 -0
- package/build/vue/sqlite-context.js +69 -0
- package/build-ngc/angular/index.d.ts +2 -0
- package/build-ngc/angular/index.js +3 -0
- package/build-ngc/angular/index.js.map +1 -0
- package/build-ngc/angular/sqlite.service.d.ts +44 -0
- package/build-ngc/angular/sqlite.service.js +85 -0
- package/build-ngc/angular/sqlite.service.js.map +1 -0
- package/build-ngc/core/index.d.ts +10 -0
- package/build-ngc/core/index.js +7 -0
- package/build-ngc/core/index.js.map +1 -0
- package/build-ngc/core/native-database.d.ts +65 -0
- package/build-ngc/core/native-database.js +14 -0
- package/build-ngc/core/native-database.js.map +1 -0
- package/build-ngc/core/native-module.d.ts +25 -0
- package/build-ngc/core/native-module.js +18 -0
- package/build-ngc/core/native-module.js.map +1 -0
- package/build-ngc/core/native-session.d.ts +20 -0
- package/build-ngc/core/native-session.js +2 -0
- package/build-ngc/core/native-session.js.map +1 -0
- package/build-ngc/core/native-statement.d.ts +45 -0
- package/build-ngc/core/native-statement.js +7 -0
- package/build-ngc/core/native-statement.js.map +1 -0
- package/build-ngc/core/param-utils.d.ts +28 -0
- package/build-ngc/core/param-utils.js +127 -0
- package/build-ngc/core/param-utils.js.map +1 -0
- package/build-ngc/core/path-utils.d.ts +6 -0
- package/build-ngc/core/path-utils.js +30 -0
- package/build-ngc/core/path-utils.js.map +1 -0
- package/build-ngc/core/query-utils.d.ts +17 -0
- package/build-ngc/core/query-utils.js +38 -0
- package/build-ngc/core/query-utils.js.map +1 -0
- package/build-ngc/core/sqlite-database.d.ts +246 -0
- package/build-ngc/core/sqlite-database.js +428 -0
- package/build-ngc/core/sqlite-database.js.map +1 -0
- package/build-ngc/core/sqlite-session.d.ts +84 -0
- package/build-ngc/core/sqlite-session.js +122 -0
- package/build-ngc/core/sqlite-session.js.map +1 -0
- package/build-ngc/core/sqlite-statement.d.ts +96 -0
- package/build-ngc/core/sqlite-statement.js +322 -0
- package/build-ngc/core/sqlite-statement.js.map +1 -0
- package/build-ngc/core/sqlite-tagged-query.d.ts +73 -0
- package/build-ngc/core/sqlite-tagged-query.js +120 -0
- package/build-ngc/core/sqlite-tagged-query.js.map +1 -0
- package/build-ngc/core/storage.d.ts +107 -0
- package/build-ngc/core/storage.js +383 -0
- package/build-ngc/core/storage.js.map +1 -0
- package/build-ngc/core/types.d.ts +30 -0
- package/build-ngc/core/types.js +2 -0
- package/build-ngc/core/types.js.map +1 -0
- package/native-link.json +12 -0
- package/package.json +141 -0
- package/src/angular/index.ts +2 -0
- package/src/angular/sqlite.service.ts +114 -0
- package/src/core/index.ts +40 -0
- package/src/core/native-database.ts +118 -0
- package/src/core/native-module.ts +57 -0
- package/src/core/native-session.ts +64 -0
- package/src/core/native-statement.ts +85 -0
- package/src/core/param-utils.ts +163 -0
- package/src/core/path-utils.ts +38 -0
- package/src/core/query-utils.ts +45 -0
- package/src/core/sqlite-database.ts +676 -0
- package/src/core/sqlite-session.ts +165 -0
- package/src/core/sqlite-statement.ts +578 -0
- package/src/core/sqlite-tagged-query.ts +160 -0
- package/src/core/storage.ts +492 -0
- package/src/core/types.ts +33 -0
- package/src/react/index.ts +2 -0
- package/src/react/sqlite-context.tsx +244 -0
- package/src/solid/index.ts +2 -0
- package/src/solid/sqlite-context.ts +156 -0
- package/src/svelte/SQLiteProvider.svelte +88 -0
- package/src/svelte/index.ts +6 -0
- package/src/svelte/sqlite-context.ts +32 -0
- package/src/svelte/svelte-compile.test-helper.ts +135 -0
- package/src/vue/index.ts +2 -0
- package/src/vue/sqlite-context.ts +105 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import type { EventSubscription } from 'expo-modules-core';
|
|
2
|
+
import { NativeDatabase } from './native-database';
|
|
3
|
+
import type { ISQLiteOpenOptions } from './native-database';
|
|
4
|
+
import { SQLiteSession } from './sqlite-session';
|
|
5
|
+
import { SQLiteStatement } from './sqlite-statement';
|
|
6
|
+
import type { ISQLiteBindParams, ISQLiteRunResult, ISQLiteVariadicBindParams } from './sqlite-statement';
|
|
7
|
+
import { SQLiteTaggedQuery } from './sqlite-tagged-query';
|
|
8
|
+
import type { IDatabaseChangeEvent, IOpenDatabaseOptions } from './types';
|
|
9
|
+
export type { ISQLiteOpenOptions } from './native-database';
|
|
10
|
+
export type { IDatabaseChangeEvent, IOnInitCallback, IOpenDatabaseOptions, } from './types';
|
|
11
|
+
/** A SQLite database. */
|
|
12
|
+
export declare class SQLiteDatabase {
|
|
13
|
+
readonly databasePath: string;
|
|
14
|
+
readonly options: ISQLiteOpenOptions;
|
|
15
|
+
readonly nativeDatabase: NativeDatabase;
|
|
16
|
+
constructor(databasePath: string, options: ISQLiteOpenOptions, nativeDatabase: NativeDatabase);
|
|
17
|
+
/** Whether the database is currently in a transaction. */
|
|
18
|
+
isInTransactionAsync(): Promise<boolean>;
|
|
19
|
+
/** Closes the database. */
|
|
20
|
+
closeAsync(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Executes all SQL queries in the supplied string.
|
|
23
|
+
* > **Note:** The queries are not escaped for you — be careful when constructing them.
|
|
24
|
+
*/
|
|
25
|
+
execAsync(source: string): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* [Serializes the database](https://sqlite.org/c3ref/serialize.html) as a `Uint8Array`.
|
|
28
|
+
* @param databaseName The attached database name. Defaults to `main`.
|
|
29
|
+
*/
|
|
30
|
+
serializeAsync(databaseName?: string): Promise<Uint8Array>;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a [prepared statement](https://www.sqlite.org/c3ref/prepare.html) from `source`.
|
|
33
|
+
*/
|
|
34
|
+
prepareAsync(source: string): Promise<SQLiteStatement>;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new session for the database.
|
|
37
|
+
* @see [`sqlite3session_create`](https://www.sqlite.org/session/sqlite3session_create.html)
|
|
38
|
+
* @param dbName The database name to create a session for. Defaults to `main`.
|
|
39
|
+
*/
|
|
40
|
+
createSessionAsync(dbName?: string): Promise<SQLiteSession>;
|
|
41
|
+
/**
|
|
42
|
+
* Loads a SQLite extension.
|
|
43
|
+
* @param libPath The path to the extension library file.
|
|
44
|
+
* @param entryPoint The extension's entry point. Inferred by
|
|
45
|
+
* [`sqlite3_load_extension`](https://www.sqlite.org/c3ref/load_extension.html) when omitted.
|
|
46
|
+
*/
|
|
47
|
+
loadExtensionAsync(libPath: string, entryPoint?: string): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Executes a transaction, committing/rolling back automatically based on `task`'s result.
|
|
50
|
+
*
|
|
51
|
+
* > **Note:** Not exclusive — other async queries can interleave, so the order of execution
|
|
52
|
+
* > relative to a query issued outside the transaction is not guaranteed. Use
|
|
53
|
+
* > `withExclusiveTransactionAsync` when that matters.
|
|
54
|
+
*/
|
|
55
|
+
withTransactionAsync(task: () => Promise<void>): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Executes a transaction, committing/rolling back automatically based on `task`'s result.
|
|
58
|
+
* The transaction may be exclusive: once it becomes a write transaction, other async write
|
|
59
|
+
* queries abort with a `database is locked` error.
|
|
60
|
+
*
|
|
61
|
+
* > **Note:** Not supported on web.
|
|
62
|
+
*
|
|
63
|
+
* @param task Any queries inside it must run on the `txn` object it receives — a private
|
|
64
|
+
* `SQLiteDatabase` subclass bound to the exclusive connection, typed here as the base class
|
|
65
|
+
* since the subclass is an implementation detail, not a public export.
|
|
66
|
+
*/
|
|
67
|
+
withExclusiveTransactionAsync(task: (txn: SQLiteDatabase) => Promise<void>): Promise<void>;
|
|
68
|
+
/** Whether the database is currently in a transaction. */
|
|
69
|
+
isInTransactionSync(): boolean;
|
|
70
|
+
/** Closes the database. */
|
|
71
|
+
closeSync(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Executes all SQL queries in the supplied string.
|
|
74
|
+
* > **Note:** The queries are not escaped for you. Running heavy tasks with this function can
|
|
75
|
+
* > block the JavaScript thread.
|
|
76
|
+
*/
|
|
77
|
+
execSync(source: string): void;
|
|
78
|
+
/**
|
|
79
|
+
* [Serializes the database](https://sqlite.org/c3ref/serialize.html) as a `Uint8Array`.
|
|
80
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
81
|
+
*/
|
|
82
|
+
serializeSync(databaseName?: string): Uint8Array;
|
|
83
|
+
/**
|
|
84
|
+
* Creates a [prepared statement](https://www.sqlite.org/c3ref/prepare.html) from `source`.
|
|
85
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
86
|
+
*/
|
|
87
|
+
prepareSync(source: string): SQLiteStatement;
|
|
88
|
+
/**
|
|
89
|
+
* Creates a new session for the database.
|
|
90
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
91
|
+
* @see [`sqlite3session_create`](https://www.sqlite.org/session/sqlite3session_create.html)
|
|
92
|
+
*/
|
|
93
|
+
createSessionSync(dbName?: string): SQLiteSession;
|
|
94
|
+
/**
|
|
95
|
+
* Loads a SQLite extension.
|
|
96
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
97
|
+
*/
|
|
98
|
+
loadExtensionSync(libPath: string, entryPoint?: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* Executes a transaction, committing/rolling back automatically based on `task`'s result.
|
|
101
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
102
|
+
*/
|
|
103
|
+
withTransactionSync(task: () => void): void;
|
|
104
|
+
/**
|
|
105
|
+
* Executes SQL queries using tagged template literals (Bun-style), automatically parameterized
|
|
106
|
+
* against SQL injection. Directly awaitable (returns rows/`ISQLiteRunResult`); use `.values()`,
|
|
107
|
+
* `.first()`, `.each()`, or the `*Sync` variants for other shapes.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```ts
|
|
111
|
+
* const users = await db.sql<User>`SELECT * FROM users WHERE age > ${21}`;
|
|
112
|
+
* const rows = await db.sql`SELECT name, age FROM users`.values();
|
|
113
|
+
* const user = await db.sql<User>`SELECT * FROM users WHERE id = ${userId}`.first();
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
sql: <T = unknown>(strings: TemplateStringsArray, ...values: unknown[]) => SQLiteTaggedQuery<T>;
|
|
117
|
+
/**
|
|
118
|
+
* A convenience wrapper around `prepareAsync()`, `SQLiteStatement.executeAsync()`, and
|
|
119
|
+
* `SQLiteStatement.finalizeAsync()`.
|
|
120
|
+
*/
|
|
121
|
+
runAsync(source: string, params: ISQLiteBindParams): Promise<ISQLiteRunResult>;
|
|
122
|
+
/** @hidden */
|
|
123
|
+
runAsync(source: string, ...params: ISQLiteVariadicBindParams): Promise<ISQLiteRunResult>;
|
|
124
|
+
/**
|
|
125
|
+
* A convenience wrapper around `prepareAsync()`, `SQLiteStatement.executeAsync()`,
|
|
126
|
+
* `ISQLiteExecuteAsyncResult.getFirstAsync()`, and `SQLiteStatement.finalizeAsync()`.
|
|
127
|
+
*/
|
|
128
|
+
getFirstAsync<T>(source: string, params: ISQLiteBindParams): Promise<T | null>;
|
|
129
|
+
/** @hidden */
|
|
130
|
+
getFirstAsync<T>(source: string, ...params: ISQLiteVariadicBindParams): Promise<T | null>;
|
|
131
|
+
/**
|
|
132
|
+
* A convenience wrapper around `prepareAsync()`, `SQLiteStatement.executeAsync()`, the
|
|
133
|
+
* `ISQLiteExecuteAsyncResult` async iterator, and `SQLiteStatement.finalizeAsync()`.
|
|
134
|
+
*/
|
|
135
|
+
getEachAsync<T>(source: string, params: ISQLiteBindParams): AsyncIterableIterator<T>;
|
|
136
|
+
/** @hidden */
|
|
137
|
+
getEachAsync<T>(source: string, ...params: ISQLiteVariadicBindParams): AsyncIterableIterator<T>;
|
|
138
|
+
/**
|
|
139
|
+
* A convenience wrapper around `prepareAsync()`, `SQLiteStatement.executeAsync()`,
|
|
140
|
+
* `ISQLiteExecuteAsyncResult.getAllAsync()`, and `SQLiteStatement.finalizeAsync()`.
|
|
141
|
+
*/
|
|
142
|
+
getAllAsync<T>(source: string, params: ISQLiteBindParams): Promise<T[]>;
|
|
143
|
+
/** @hidden */
|
|
144
|
+
getAllAsync<T>(source: string, ...params: ISQLiteVariadicBindParams): Promise<T[]>;
|
|
145
|
+
/**
|
|
146
|
+
* A convenience wrapper around `prepareSync()`, `SQLiteStatement.executeSync()`, and
|
|
147
|
+
* `SQLiteStatement.finalizeSync()`.
|
|
148
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
149
|
+
*/
|
|
150
|
+
runSync(source: string, params: ISQLiteBindParams): ISQLiteRunResult;
|
|
151
|
+
/** @hidden */
|
|
152
|
+
runSync(source: string, ...params: ISQLiteVariadicBindParams): ISQLiteRunResult;
|
|
153
|
+
/**
|
|
154
|
+
* A convenience wrapper around `prepareSync()`, `SQLiteStatement.executeSync()`,
|
|
155
|
+
* `ISQLiteExecuteSyncResult.getFirstSync()`, and `SQLiteStatement.finalizeSync()`.
|
|
156
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
157
|
+
*/
|
|
158
|
+
getFirstSync<T>(source: string, params: ISQLiteBindParams): T | null;
|
|
159
|
+
/** @hidden */
|
|
160
|
+
getFirstSync<T>(source: string, ...params: ISQLiteVariadicBindParams): T | null;
|
|
161
|
+
/**
|
|
162
|
+
* A convenience wrapper around `prepareSync()`, `SQLiteStatement.executeSync()`, the
|
|
163
|
+
* `ISQLiteExecuteSyncResult` iterator, and `SQLiteStatement.finalizeSync()`.
|
|
164
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
165
|
+
*/
|
|
166
|
+
getEachSync<T>(source: string, params: ISQLiteBindParams): IterableIterator<T>;
|
|
167
|
+
/** @hidden */
|
|
168
|
+
getEachSync<T>(source: string, ...params: ISQLiteVariadicBindParams): IterableIterator<T>;
|
|
169
|
+
/**
|
|
170
|
+
* A convenience wrapper around `prepareSync()`, `SQLiteStatement.executeSync()`,
|
|
171
|
+
* `ISQLiteExecuteSyncResult.getAllSync()`, and `SQLiteStatement.finalizeSync()`.
|
|
172
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
173
|
+
*/
|
|
174
|
+
getAllSync<T>(source: string, params: ISQLiteBindParams): T[];
|
|
175
|
+
/** @hidden */
|
|
176
|
+
getAllSync<T>(source: string, ...params: ISQLiteVariadicBindParams): T[];
|
|
177
|
+
/** Synchronizes the local database with the remote libSQL server (libSQL integration only). */
|
|
178
|
+
syncLibSQL(): Promise<void>;
|
|
179
|
+
}
|
|
180
|
+
/** The default directory new databases are created in. */
|
|
181
|
+
export declare const defaultDatabaseDirectory: string;
|
|
182
|
+
/**
|
|
183
|
+
* Pre-bundled SQLite extensions. Bundling one (e.g. `sqlite-vec`) is a manual native-config
|
|
184
|
+
* step this package does not automate — see the README.
|
|
185
|
+
*/
|
|
186
|
+
export declare const bundledExtensions: Record<string, {
|
|
187
|
+
libPath: string;
|
|
188
|
+
entryPoint: string;
|
|
189
|
+
} | undefined>;
|
|
190
|
+
/**
|
|
191
|
+
* Opens a database.
|
|
192
|
+
* @param databaseName The database file name to open.
|
|
193
|
+
* @param options Open options — see `IOpenDatabaseOptions` for the `onInit` deviation from
|
|
194
|
+
* upstream (documented in the README).
|
|
195
|
+
* @param directory The directory the database file is located in. Defaults to
|
|
196
|
+
* `defaultDatabaseDirectory`.
|
|
197
|
+
*/
|
|
198
|
+
export declare function openDatabaseAsync(databaseName: string, options?: IOpenDatabaseOptions, directory?: string): Promise<SQLiteDatabase>;
|
|
199
|
+
/**
|
|
200
|
+
* Opens a database.
|
|
201
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
202
|
+
*/
|
|
203
|
+
export declare function openDatabaseSync(databaseName: string, options?: IOpenDatabaseOptions, directory?: string): SQLiteDatabase;
|
|
204
|
+
/**
|
|
205
|
+
* Given `Uint8Array` data, [deserializes it to an in-memory database](https://sqlite.org/c3ref/deserialize.html).
|
|
206
|
+
* @param serializedData The binary array from `SQLiteDatabase.serializeAsync()`.
|
|
207
|
+
*/
|
|
208
|
+
export declare function deserializeDatabaseAsync(serializedData: Uint8Array, options?: ISQLiteOpenOptions): Promise<SQLiteDatabase>;
|
|
209
|
+
/**
|
|
210
|
+
* Given `Uint8Array` data, [deserializes it to an in-memory database](https://sqlite.org/c3ref/deserialize.html).
|
|
211
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
212
|
+
*/
|
|
213
|
+
export declare function deserializeDatabaseSync(serializedData: Uint8Array, options?: ISQLiteOpenOptions): SQLiteDatabase;
|
|
214
|
+
/** Deletes a database file. */
|
|
215
|
+
export declare function deleteDatabaseAsync(databaseName: string, directory?: string): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Deletes a database file.
|
|
218
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
219
|
+
*/
|
|
220
|
+
export declare function deleteDatabaseSync(databaseName: string, directory?: string): void;
|
|
221
|
+
/**
|
|
222
|
+
* Backs up a database to another database.
|
|
223
|
+
* @see https://www.sqlite.org/c3ref/backup_finish.html
|
|
224
|
+
*/
|
|
225
|
+
export declare function backupDatabaseAsync(options: {
|
|
226
|
+
sourceDatabase: SQLiteDatabase;
|
|
227
|
+
sourceDatabaseName?: string;
|
|
228
|
+
destDatabase: SQLiteDatabase;
|
|
229
|
+
destDatabaseName?: string;
|
|
230
|
+
}): Promise<void>;
|
|
231
|
+
/**
|
|
232
|
+
* Backs up a database to another database.
|
|
233
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
234
|
+
* @see https://www.sqlite.org/c3ref/backup_finish.html
|
|
235
|
+
*/
|
|
236
|
+
export declare function backupDatabaseSync(options: {
|
|
237
|
+
sourceDatabase: SQLiteDatabase;
|
|
238
|
+
sourceDatabaseName?: string;
|
|
239
|
+
destDatabase: SQLiteDatabase;
|
|
240
|
+
destDatabaseName?: string;
|
|
241
|
+
}): void;
|
|
242
|
+
/**
|
|
243
|
+
* Adds a listener for database changes.
|
|
244
|
+
* > **Note:** requires `enableChangeListener: true` in `ISQLiteOpenOptions` when opening.
|
|
245
|
+
*/
|
|
246
|
+
export declare function addDatabaseChangeListener(listener: (event: IDatabaseChangeEvent) => void): EventSubscription;
|
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
// Ported from expo-sqlite's SQLiteDatabase.ts (.vendors/expo @ origin/sdk-57,
|
|
2
|
+
// packages/expo-sqlite/src/SQLiteDatabase.ts), renamed with this repo's `I`-prefix convention.
|
|
3
|
+
//
|
|
4
|
+
// Not ported: `registerDatabaseForDevToolsAsync`/`unregisterDatabaseForDevToolsAsync`
|
|
5
|
+
// (SQLiteDevToolsClient.ts) — wiring for Expo's own DevTools browser extension, which this
|
|
6
|
+
// project has no equivalent of and does not otherwise depend on.
|
|
7
|
+
import { Platform } from 'expo-modules-core';
|
|
8
|
+
import { expoSQLite } from './native-module';
|
|
9
|
+
import { NativeDatabase, flattenOpenOptions } from './native-database';
|
|
10
|
+
import { SQLiteSession } from './sqlite-session';
|
|
11
|
+
import { SQLiteStatement } from './sqlite-statement';
|
|
12
|
+
import { SQLiteTaggedQuery } from './sqlite-tagged-query';
|
|
13
|
+
import { createDatabasePath } from './path-utils';
|
|
14
|
+
/** A SQLite database. */
|
|
15
|
+
export class SQLiteDatabase {
|
|
16
|
+
databasePath;
|
|
17
|
+
options;
|
|
18
|
+
nativeDatabase;
|
|
19
|
+
constructor(databasePath, options, nativeDatabase) {
|
|
20
|
+
this.databasePath = databasePath;
|
|
21
|
+
this.options = options;
|
|
22
|
+
this.nativeDatabase = nativeDatabase;
|
|
23
|
+
}
|
|
24
|
+
/** Whether the database is currently in a transaction. */
|
|
25
|
+
isInTransactionAsync() {
|
|
26
|
+
return this.nativeDatabase.isInTransactionAsync();
|
|
27
|
+
}
|
|
28
|
+
/** Closes the database. */
|
|
29
|
+
closeAsync() {
|
|
30
|
+
return this.nativeDatabase.closeAsync();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Executes all SQL queries in the supplied string.
|
|
34
|
+
* > **Note:** The queries are not escaped for you — be careful when constructing them.
|
|
35
|
+
*/
|
|
36
|
+
execAsync(source) {
|
|
37
|
+
return this.nativeDatabase.execAsync(source);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* [Serializes the database](https://sqlite.org/c3ref/serialize.html) as a `Uint8Array`.
|
|
41
|
+
* @param databaseName The attached database name. Defaults to `main`.
|
|
42
|
+
*/
|
|
43
|
+
serializeAsync(databaseName = 'main') {
|
|
44
|
+
return this.nativeDatabase.serializeAsync(databaseName);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Creates a [prepared statement](https://www.sqlite.org/c3ref/prepare.html) from `source`.
|
|
48
|
+
*/
|
|
49
|
+
async prepareAsync(source) {
|
|
50
|
+
const nativeStatement = new expoSQLite.NativeStatement();
|
|
51
|
+
await this.nativeDatabase.prepareAsync(nativeStatement, source);
|
|
52
|
+
return new SQLiteStatement(this.nativeDatabase, nativeStatement);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new session for the database.
|
|
56
|
+
* @see [`sqlite3session_create`](https://www.sqlite.org/session/sqlite3session_create.html)
|
|
57
|
+
* @param dbName The database name to create a session for. Defaults to `main`.
|
|
58
|
+
*/
|
|
59
|
+
async createSessionAsync(dbName = 'main') {
|
|
60
|
+
const nativeSession = new expoSQLite.NativeSession();
|
|
61
|
+
await this.nativeDatabase.createSessionAsync(nativeSession, dbName);
|
|
62
|
+
return new SQLiteSession(this.nativeDatabase, nativeSession);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Loads a SQLite extension.
|
|
66
|
+
* @param libPath The path to the extension library file.
|
|
67
|
+
* @param entryPoint The extension's entry point. Inferred by
|
|
68
|
+
* [`sqlite3_load_extension`](https://www.sqlite.org/c3ref/load_extension.html) when omitted.
|
|
69
|
+
*/
|
|
70
|
+
loadExtensionAsync(libPath, entryPoint) {
|
|
71
|
+
return this.nativeDatabase.loadExtensionAsync(libPath, entryPoint);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Executes a transaction, committing/rolling back automatically based on `task`'s result.
|
|
75
|
+
*
|
|
76
|
+
* > **Note:** Not exclusive — other async queries can interleave, so the order of execution
|
|
77
|
+
* > relative to a query issued outside the transaction is not guaranteed. Use
|
|
78
|
+
* > `withExclusiveTransactionAsync` when that matters.
|
|
79
|
+
*/
|
|
80
|
+
async withTransactionAsync(task) {
|
|
81
|
+
try {
|
|
82
|
+
await this.execAsync('BEGIN');
|
|
83
|
+
await task();
|
|
84
|
+
await this.execAsync('COMMIT');
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
await this.execAsync('ROLLBACK');
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Executes a transaction, committing/rolling back automatically based on `task`'s result.
|
|
93
|
+
* The transaction may be exclusive: once it becomes a write transaction, other async write
|
|
94
|
+
* queries abort with a `database is locked` error.
|
|
95
|
+
*
|
|
96
|
+
* > **Note:** Not supported on web.
|
|
97
|
+
*
|
|
98
|
+
* @param task Any queries inside it must run on the `txn` object it receives — a private
|
|
99
|
+
* `SQLiteDatabase` subclass bound to the exclusive connection, typed here as the base class
|
|
100
|
+
* since the subclass is an implementation detail, not a public export.
|
|
101
|
+
*/
|
|
102
|
+
async withExclusiveTransactionAsync(task) {
|
|
103
|
+
if (Platform.OS === 'web') {
|
|
104
|
+
throw new Error('withExclusiveTransactionAsync is not supported on web');
|
|
105
|
+
}
|
|
106
|
+
const transaction = await SQLiteTransaction.createAsync(this);
|
|
107
|
+
let error;
|
|
108
|
+
try {
|
|
109
|
+
await transaction.execAsync('BEGIN');
|
|
110
|
+
await task(transaction);
|
|
111
|
+
await transaction.execAsync('COMMIT');
|
|
112
|
+
}
|
|
113
|
+
catch (thrown) {
|
|
114
|
+
await transaction.execAsync('ROLLBACK');
|
|
115
|
+
error = thrown;
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
await transaction.closeAsync();
|
|
119
|
+
}
|
|
120
|
+
if (error !== undefined) {
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/** Whether the database is currently in a transaction. */
|
|
125
|
+
isInTransactionSync() {
|
|
126
|
+
return this.nativeDatabase.isInTransactionSync();
|
|
127
|
+
}
|
|
128
|
+
/** Closes the database. */
|
|
129
|
+
closeSync() {
|
|
130
|
+
return this.nativeDatabase.closeSync();
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Executes all SQL queries in the supplied string.
|
|
134
|
+
* > **Note:** The queries are not escaped for you. Running heavy tasks with this function can
|
|
135
|
+
* > block the JavaScript thread.
|
|
136
|
+
*/
|
|
137
|
+
execSync(source) {
|
|
138
|
+
return this.nativeDatabase.execSync(source);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* [Serializes the database](https://sqlite.org/c3ref/serialize.html) as a `Uint8Array`.
|
|
142
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
143
|
+
*/
|
|
144
|
+
serializeSync(databaseName = 'main') {
|
|
145
|
+
return this.nativeDatabase.serializeSync(databaseName);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Creates a [prepared statement](https://www.sqlite.org/c3ref/prepare.html) from `source`.
|
|
149
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
150
|
+
*/
|
|
151
|
+
prepareSync(source) {
|
|
152
|
+
const nativeStatement = new expoSQLite.NativeStatement();
|
|
153
|
+
this.nativeDatabase.prepareSync(nativeStatement, source);
|
|
154
|
+
return new SQLiteStatement(this.nativeDatabase, nativeStatement);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Creates a new session for the database.
|
|
158
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
159
|
+
* @see [`sqlite3session_create`](https://www.sqlite.org/session/sqlite3session_create.html)
|
|
160
|
+
*/
|
|
161
|
+
createSessionSync(dbName = 'main') {
|
|
162
|
+
const nativeSession = new expoSQLite.NativeSession();
|
|
163
|
+
this.nativeDatabase.createSessionSync(nativeSession, dbName);
|
|
164
|
+
return new SQLiteSession(this.nativeDatabase, nativeSession);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Loads a SQLite extension.
|
|
168
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
169
|
+
*/
|
|
170
|
+
loadExtensionSync(libPath, entryPoint) {
|
|
171
|
+
this.nativeDatabase.loadExtensionSync(libPath, entryPoint);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Executes a transaction, committing/rolling back automatically based on `task`'s result.
|
|
175
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
176
|
+
*/
|
|
177
|
+
withTransactionSync(task) {
|
|
178
|
+
try {
|
|
179
|
+
this.execSync('BEGIN');
|
|
180
|
+
task();
|
|
181
|
+
this.execSync('COMMIT');
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
this.execSync('ROLLBACK');
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Executes SQL queries using tagged template literals (Bun-style), automatically parameterized
|
|
190
|
+
* against SQL injection. Directly awaitable (returns rows/`ISQLiteRunResult`); use `.values()`,
|
|
191
|
+
* `.first()`, `.each()`, or the `*Sync` variants for other shapes.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* const users = await db.sql<User>`SELECT * FROM users WHERE age > ${21}`;
|
|
196
|
+
* const rows = await db.sql`SELECT name, age FROM users`.values();
|
|
197
|
+
* const user = await db.sql<User>`SELECT * FROM users WHERE id = ${userId}`.first();
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
sql = (strings, ...values) => new SQLiteTaggedQuery(this, strings, values);
|
|
201
|
+
// `any[]`: the implementation signature of an overloaded function is not itself callable, so
|
|
202
|
+
// TS checks `statement.executeAsync(...params)` below against ITS overloads, not against
|
|
203
|
+
// whatever narrower type is written here — `unknown[]` fails that check for every one of
|
|
204
|
+
// these forwarding methods, matching upstream's own `any[]` for the identical reason.
|
|
205
|
+
async runAsync(source, ...params) {
|
|
206
|
+
const statement = await this.prepareAsync(source);
|
|
207
|
+
let result;
|
|
208
|
+
try {
|
|
209
|
+
result = await statement.executeAsync(...params);
|
|
210
|
+
}
|
|
211
|
+
finally {
|
|
212
|
+
await statement.finalizeAsync();
|
|
213
|
+
}
|
|
214
|
+
return result;
|
|
215
|
+
}
|
|
216
|
+
async getFirstAsync(source, ...params) {
|
|
217
|
+
const statement = await this.prepareAsync(source);
|
|
218
|
+
let firstRow;
|
|
219
|
+
try {
|
|
220
|
+
const result = await statement.executeAsync(...params);
|
|
221
|
+
firstRow = await result.getFirstAsync();
|
|
222
|
+
}
|
|
223
|
+
finally {
|
|
224
|
+
await statement.finalizeAsync();
|
|
225
|
+
}
|
|
226
|
+
return firstRow;
|
|
227
|
+
}
|
|
228
|
+
async *getEachAsync(source, ...params) {
|
|
229
|
+
const statement = await this.prepareAsync(source);
|
|
230
|
+
try {
|
|
231
|
+
const result = await statement.executeAsync(...params);
|
|
232
|
+
for await (const row of result) {
|
|
233
|
+
yield row;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
finally {
|
|
237
|
+
await statement.finalizeAsync();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
async getAllAsync(source, ...params) {
|
|
241
|
+
const statement = await this.prepareAsync(source);
|
|
242
|
+
let allRows;
|
|
243
|
+
try {
|
|
244
|
+
const result = await statement.executeAsync(...params);
|
|
245
|
+
allRows = await result.getAllAsync();
|
|
246
|
+
}
|
|
247
|
+
finally {
|
|
248
|
+
await statement.finalizeAsync();
|
|
249
|
+
}
|
|
250
|
+
return allRows;
|
|
251
|
+
}
|
|
252
|
+
runSync(source, ...params) {
|
|
253
|
+
const statement = this.prepareSync(source);
|
|
254
|
+
let result;
|
|
255
|
+
try {
|
|
256
|
+
result = statement.executeSync(...params);
|
|
257
|
+
}
|
|
258
|
+
finally {
|
|
259
|
+
statement.finalizeSync();
|
|
260
|
+
}
|
|
261
|
+
return result;
|
|
262
|
+
}
|
|
263
|
+
getFirstSync(source, ...params) {
|
|
264
|
+
const statement = this.prepareSync(source);
|
|
265
|
+
let firstRow;
|
|
266
|
+
try {
|
|
267
|
+
const result = statement.executeSync(...params);
|
|
268
|
+
firstRow = result.getFirstSync();
|
|
269
|
+
}
|
|
270
|
+
finally {
|
|
271
|
+
statement.finalizeSync();
|
|
272
|
+
}
|
|
273
|
+
return firstRow;
|
|
274
|
+
}
|
|
275
|
+
*getEachSync(source, ...params) {
|
|
276
|
+
const statement = this.prepareSync(source);
|
|
277
|
+
try {
|
|
278
|
+
const result = statement.executeSync(...params);
|
|
279
|
+
for (const row of result) {
|
|
280
|
+
yield row;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
finally {
|
|
284
|
+
statement.finalizeSync();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
getAllSync(source, ...params) {
|
|
288
|
+
const statement = this.prepareSync(source);
|
|
289
|
+
let allRows;
|
|
290
|
+
try {
|
|
291
|
+
const result = statement.executeSync(...params);
|
|
292
|
+
allRows = result.getAllSync();
|
|
293
|
+
}
|
|
294
|
+
finally {
|
|
295
|
+
statement.finalizeSync();
|
|
296
|
+
}
|
|
297
|
+
return allRows;
|
|
298
|
+
}
|
|
299
|
+
/** Synchronizes the local database with the remote libSQL server (libSQL integration only). */
|
|
300
|
+
syncLibSQL() {
|
|
301
|
+
if (typeof this.nativeDatabase.syncLibSQL !== 'function') {
|
|
302
|
+
throw new Error('syncLibSQL is not supported in the current environment');
|
|
303
|
+
}
|
|
304
|
+
return this.nativeDatabase.syncLibSQL();
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
/** The default directory new databases are created in. */
|
|
308
|
+
export const defaultDatabaseDirectory = expoSQLite.defaultDatabaseDirectory;
|
|
309
|
+
/**
|
|
310
|
+
* Pre-bundled SQLite extensions. Bundling one (e.g. `sqlite-vec`) is a manual native-config
|
|
311
|
+
* step this package does not automate — see the README.
|
|
312
|
+
*/
|
|
313
|
+
export const bundledExtensions = expoSQLite.bundledExtensions;
|
|
314
|
+
async function runOnInit(db, onInit) {
|
|
315
|
+
if (onInit) {
|
|
316
|
+
await onInit(db);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Opens a database.
|
|
321
|
+
* @param databaseName The database file name to open.
|
|
322
|
+
* @param options Open options — see `IOpenDatabaseOptions` for the `onInit` deviation from
|
|
323
|
+
* upstream (documented in the README).
|
|
324
|
+
* @param directory The directory the database file is located in. Defaults to
|
|
325
|
+
* `defaultDatabaseDirectory`.
|
|
326
|
+
*/
|
|
327
|
+
export async function openDatabaseAsync(databaseName, options, directory) {
|
|
328
|
+
const { onInit, ...openOptions } = options ?? {};
|
|
329
|
+
const databasePath = createDatabasePath(databaseName, directory);
|
|
330
|
+
await expoSQLite.ensureDatabasePathExistsAsync(databasePath);
|
|
331
|
+
const nativeDatabase = new expoSQLite.NativeDatabase(databasePath, flattenOpenOptions(openOptions));
|
|
332
|
+
await nativeDatabase.initAsync();
|
|
333
|
+
const database = new SQLiteDatabase(databasePath, openOptions, nativeDatabase);
|
|
334
|
+
await runOnInit(database, onInit);
|
|
335
|
+
return database;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Opens a database.
|
|
339
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
340
|
+
*/
|
|
341
|
+
export function openDatabaseSync(databaseName, options, directory) {
|
|
342
|
+
const { onInit, ...openOptions } = options ?? {};
|
|
343
|
+
const databasePath = createDatabasePath(databaseName, directory);
|
|
344
|
+
expoSQLite.ensureDatabasePathExistsSync(databasePath);
|
|
345
|
+
const nativeDatabase = new expoSQLite.NativeDatabase(databasePath, flattenOpenOptions(openOptions));
|
|
346
|
+
nativeDatabase.initSync();
|
|
347
|
+
const database = new SQLiteDatabase(databasePath, openOptions, nativeDatabase);
|
|
348
|
+
if (onInit) {
|
|
349
|
+
const result = onInit(database);
|
|
350
|
+
if (result instanceof Promise) {
|
|
351
|
+
throw new Error('openDatabaseSync: onInit returned a Promise — pass a synchronous callback, or use openDatabaseAsync.');
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return database;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Given `Uint8Array` data, [deserializes it to an in-memory database](https://sqlite.org/c3ref/deserialize.html).
|
|
358
|
+
* @param serializedData The binary array from `SQLiteDatabase.serializeAsync()`.
|
|
359
|
+
*/
|
|
360
|
+
export async function deserializeDatabaseAsync(serializedData, options) {
|
|
361
|
+
const openOptions = options ?? {};
|
|
362
|
+
const nativeDatabase = new expoSQLite.NativeDatabase(':memory:', flattenOpenOptions(openOptions), serializedData);
|
|
363
|
+
await nativeDatabase.initAsync();
|
|
364
|
+
return new SQLiteDatabase(':memory:', openOptions, nativeDatabase);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Given `Uint8Array` data, [deserializes it to an in-memory database](https://sqlite.org/c3ref/deserialize.html).
|
|
368
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
369
|
+
*/
|
|
370
|
+
export function deserializeDatabaseSync(serializedData, options) {
|
|
371
|
+
const openOptions = options ?? {};
|
|
372
|
+
const nativeDatabase = new expoSQLite.NativeDatabase(':memory:', flattenOpenOptions(openOptions), serializedData);
|
|
373
|
+
nativeDatabase.initSync();
|
|
374
|
+
return new SQLiteDatabase(':memory:', openOptions, nativeDatabase);
|
|
375
|
+
}
|
|
376
|
+
/** Deletes a database file. */
|
|
377
|
+
export async function deleteDatabaseAsync(databaseName, directory) {
|
|
378
|
+
const databasePath = createDatabasePath(databaseName, directory);
|
|
379
|
+
return await expoSQLite.deleteDatabaseAsync(databasePath);
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Deletes a database file.
|
|
383
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
384
|
+
*/
|
|
385
|
+
export function deleteDatabaseSync(databaseName, directory) {
|
|
386
|
+
const databasePath = createDatabasePath(databaseName, directory);
|
|
387
|
+
return expoSQLite.deleteDatabaseSync(databasePath);
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Backs up a database to another database.
|
|
391
|
+
* @see https://www.sqlite.org/c3ref/backup_finish.html
|
|
392
|
+
*/
|
|
393
|
+
export function backupDatabaseAsync(options) {
|
|
394
|
+
const { sourceDatabase, sourceDatabaseName, destDatabase, destDatabaseName } = options;
|
|
395
|
+
return expoSQLite.backupDatabaseAsync(destDatabase.nativeDatabase, destDatabaseName ?? 'main', sourceDatabase.nativeDatabase, sourceDatabaseName ?? 'main');
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Backs up a database to another database.
|
|
399
|
+
* > **Note:** Running heavy tasks with this function can block the JavaScript thread.
|
|
400
|
+
* @see https://www.sqlite.org/c3ref/backup_finish.html
|
|
401
|
+
*/
|
|
402
|
+
export function backupDatabaseSync(options) {
|
|
403
|
+
const { sourceDatabase, sourceDatabaseName, destDatabase, destDatabaseName } = options;
|
|
404
|
+
return expoSQLite.backupDatabaseSync(destDatabase.nativeDatabase, destDatabaseName ?? 'main', sourceDatabase.nativeDatabase, sourceDatabaseName ?? 'main');
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Adds a listener for database changes.
|
|
408
|
+
* > **Note:** requires `enableChangeListener: true` in `ISQLiteOpenOptions` when opening.
|
|
409
|
+
*/
|
|
410
|
+
export function addDatabaseChangeListener(listener) {
|
|
411
|
+
return expoSQLite.addListener('onDatabaseChange', listener);
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* A new connection specifically used by `withExclusiveTransactionAsync`.
|
|
415
|
+
* @hidden not exposing all the database methods to the public API surface
|
|
416
|
+
*/
|
|
417
|
+
class SQLiteTransaction extends SQLiteDatabase {
|
|
418
|
+
static async createAsync(db) {
|
|
419
|
+
const options = {
|
|
420
|
+
...db.options,
|
|
421
|
+
useNewConnection: true,
|
|
422
|
+
};
|
|
423
|
+
const nativeDatabase = new expoSQLite.NativeDatabase(db.databasePath, flattenOpenOptions(options));
|
|
424
|
+
await nativeDatabase.initAsync();
|
|
425
|
+
return new SQLiteTransaction(db.databasePath, options, nativeDatabase);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
//# sourceMappingURL=sqlite-database.js.map
|