expo-sqlite 16.1.0-canary-20251118-4ca99d5 → 16.1.0-canary-20251118-8f7ee64

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/android/build.gradle +2 -2
  3. package/build/SQLiteDatabase.d.ts +35 -0
  4. package/build/SQLiteDatabase.d.ts.map +1 -1
  5. package/build/SQLiteDatabase.js +35 -0
  6. package/build/SQLiteDatabase.js.map +1 -1
  7. package/build/SQLiteTaggedQuery.d.ts +116 -0
  8. package/build/SQLiteTaggedQuery.d.ts.map +1 -0
  9. package/build/SQLiteTaggedQuery.js +160 -0
  10. package/build/SQLiteTaggedQuery.js.map +1 -0
  11. package/build/index.d.ts +1 -0
  12. package/build/index.d.ts.map +1 -1
  13. package/build/index.js +1 -0
  14. package/build/index.js.map +1 -1
  15. package/build/paramUtils.d.ts.map +1 -1
  16. package/build/paramUtils.js +3 -0
  17. package/build/paramUtils.js.map +1 -1
  18. package/build/queryUtils.d.ts +25 -0
  19. package/build/queryUtils.d.ts.map +1 -0
  20. package/build/queryUtils.js +44 -0
  21. package/build/queryUtils.js.map +1 -0
  22. package/expo-module.config.json +1 -1
  23. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5.module → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.module} +7 -7
  24. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.module.md5 +1 -0
  25. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.module.sha1 +1 -0
  26. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.module.sha256 +1 -0
  27. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.module.sha512 +1 -0
  28. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5.pom → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.pom} +1 -1
  29. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.pom.md5 +1 -0
  30. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.pom.sha1 +1 -0
  31. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.pom.sha256 +1 -0
  32. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.pom.sha512 +1 -0
  33. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml +4 -4
  34. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml.md5 +1 -1
  35. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml.sha1 +1 -1
  36. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml.sha256 +1 -1
  37. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml.sha512 +1 -1
  38. package/package.json +3 -3
  39. package/src/SQLiteDatabase.ts +37 -0
  40. package/src/SQLiteTaggedQuery.ts +179 -0
  41. package/src/index.ts +1 -0
  42. package/src/paramUtils.ts +2 -0
  43. package/src/queryUtils.ts +55 -0
  44. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5.module.md5 +0 -1
  45. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5.module.sha1 +0 -1
  46. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5.module.sha256 +0 -1
  47. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5.module.sha512 +0 -1
  48. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5.pom.md5 +0 -1
  49. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5.pom.sha1 +0 -1
  50. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5.pom.sha256 +0 -1
  51. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5.pom.sha512 +0 -1
  52. /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5-sources.jar → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64-sources.jar} +0 -0
  53. /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5-sources.jar.md5 → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64-sources.jar.md5} +0 -0
  54. /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5-sources.jar.sha1 → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64-sources.jar.sha1} +0 -0
  55. /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5-sources.jar.sha256 → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64-sources.jar.sha256} +0 -0
  56. /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5-sources.jar.sha512 → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64-sources.jar.sha512} +0 -0
  57. /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5.aar → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.aar} +0 -0
  58. /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5.aar.md5 → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.aar.md5} +0 -0
  59. /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5.aar.sha1 → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.aar.sha1} +0 -0
  60. /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5.aar.sha256 → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.aar.sha256} +0 -0
  61. /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.1.0-canary-20251118-4ca99d5/expo.modules.sqlite-16.1.0-canary-20251118-4ca99d5.aar.sha512 → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.aar.sha512} +0 -0
package/CHANGELOG.md CHANGED
@@ -7,6 +7,7 @@
7
7
  ### 🎉 New features
8
8
 
9
9
  - Added SQLite inspector devtools plugin. ([#40872](https://github.com/expo/expo/pull/40872), [#40900](https://github.com/expo/expo/pull/40900) by [@kudo](https://github.com/kudo))
10
+ - Added tagged template literals support. ([#40972](https://github.com/expo/expo/pull/40972) by [@kudo](https://github.com/kudo))
10
11
 
11
12
  ### 🐛 Bug fixes
12
13
 
@@ -46,13 +46,13 @@ def reactNativeArchitectures() {
46
46
  }
47
47
 
48
48
  group = 'host.exp.exponent'
49
- version = '16.1.0-canary-20251118-4ca99d5'
49
+ version = '16.1.0-canary-20251118-8f7ee64'
50
50
 
51
51
  android {
52
52
  namespace "expo.modules.sqlite"
53
53
  defaultConfig {
54
54
  versionCode 18
55
- versionName "16.1.0-canary-20251118-4ca99d5"
55
+ versionName "16.1.0-canary-20251118-8f7ee64"
56
56
  buildConfigField "boolean", "USE_LIBSQL", project.ext.USE_LIBSQL.toString()
57
57
  buildConfigField "boolean", "WITH_SQLITE_VEC", project.ext.WITH_SQLITE_VEC.toString()
58
58
 
@@ -2,6 +2,7 @@ import { type EventSubscription } from 'expo-modules-core';
2
2
  import { NativeDatabase, SQLiteOpenOptions } from './NativeDatabase';
3
3
  import { SQLiteSession } from './SQLiteSession';
4
4
  import { SQLiteBindParams, SQLiteRunResult, SQLiteStatement, SQLiteVariadicBindParams } from './SQLiteStatement';
5
+ import { SQLiteTaggedQuery } from './SQLiteTaggedQuery';
5
6
  export { SQLiteOpenOptions };
6
7
  /**
7
8
  * A SQLite database.
@@ -188,6 +189,40 @@ export declare class SQLiteDatabase {
188
189
  * @param task An async function to execute within a transaction.
189
190
  */
190
191
  withTransactionSync(task: () => void): void;
192
+ /**
193
+ * Execute SQL queries using tagged template literals (Bun-style API).
194
+ * Queries are automatically protected against SQL injection using prepared statements.
195
+ *
196
+ * The query result is directly awaitable and returns an array of objects by default.
197
+ * Use `.values()`, `.first()`, or `.each()` for different result formats.
198
+ *
199
+ * @example
200
+ * ```ts
201
+ * // Direct await - returns array of objects
202
+ * const users = await sql<User>`SELECT * FROM users WHERE age > ${21}`;
203
+ *
204
+ * // Get first row only
205
+ * const user = await sql<User>`SELECT * FROM users WHERE id = ${userId}`.first();
206
+ *
207
+ * // Get values as arrays
208
+ * const rows = await sql`SELECT name, age FROM users`.values();
209
+ * // Returns: [["Alice", 30], ["Bob", 25]]
210
+ *
211
+ * // INSERT/UPDATE/DELETE - returns SQLiteRunResult
212
+ * const result = await sql`INSERT INTO users (name, age) VALUES (${name}, ${age})` as SQLiteRunResult;
213
+ * console.log('Inserted row:', result.lastInsertRowId);
214
+ *
215
+ * // Iteration
216
+ * for await (const user of db<User>`SELECT * FROM users`.each()) {
217
+ * console.log(user.name);
218
+ * }
219
+ *
220
+ * // Synchronous API
221
+ * const users = sql<User>`SELECT * FROM users WHERE age > ${21}`.allSync();
222
+ * const user = sql<User>`SELECT * FROM users WHERE id = ${userId}`.firstSync();
223
+ * ```
224
+ */
225
+ sql: <T = unknown>(strings: TemplateStringsArray, ...values: unknown[]) => SQLiteTaggedQuery<T>;
191
226
  /**
192
227
  * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).
193
228
  * @param source A string containing the SQL query.
@@ -1 +1 @@
1
- {"version":3,"file":"SQLiteDatabase.d.ts","sourceRoot":"","sources":["../src/SQLiteDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,OAAO,EAAsB,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAKzF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,gBAAgB,EAGhB,eAAe,EACf,eAAe,EACf,wBAAwB,EACzB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B;;GAEG;AACH,qBAAa,cAAc;aAEP,YAAY,EAAE,MAAM;aACpB,OAAO,EAAE,iBAAiB;aAC1B,cAAc,EAAE,cAAc;gBAF9B,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,iBAAiB,EAC1B,cAAc,EAAE,cAAc;IAGhD;;OAEG;IACI,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC;IAI/C;;OAEG;IACI,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAOlC;;;;;OAKG;IACI,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C;;;;OAIG;IACI,cAAc,CAAC,YAAY,GAAE,MAAe,GAAG,OAAO,CAAC,UAAU,CAAC;IAIzE;;;;OAIG;IACU,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAMnE;;;;OAIG;IACU,kBAAkB,CAAC,MAAM,GAAE,MAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAMhF;;;;;;;;;;;;;;;;;;;OAmBG;IACI,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9E;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flattenOpenOptions } from './NativeDatabase';
4
4
  import { registerDatabaseForDevToolsAsync, unregisterDatabaseForDevToolsAsync, } from './SQLiteDevToolsClient';
5
5
  import { SQLiteSession } from './SQLiteSession';
6
6
  import { SQLiteStatement, } from './SQLiteStatement';
7
+ import { SQLiteTaggedQuery } from './SQLiteTaggedQuery';
7
8
  import { createDatabasePath } from './pathUtils';
8
9
  /**
9
10
  * A SQLite database.
@@ -277,6 +278,40 @@ export class SQLiteDatabase {
277
278
  throw e;
278
279
  }
279
280
  }
281
+ /**
282
+ * Execute SQL queries using tagged template literals (Bun-style API).
283
+ * Queries are automatically protected against SQL injection using prepared statements.
284
+ *
285
+ * The query result is directly awaitable and returns an array of objects by default.
286
+ * Use `.values()`, `.first()`, or `.each()` for different result formats.
287
+ *
288
+ * @example
289
+ * ```ts
290
+ * // Direct await - returns array of objects
291
+ * const users = await sql<User>`SELECT * FROM users WHERE age > ${21}`;
292
+ *
293
+ * // Get first row only
294
+ * const user = await sql<User>`SELECT * FROM users WHERE id = ${userId}`.first();
295
+ *
296
+ * // Get values as arrays
297
+ * const rows = await sql`SELECT name, age FROM users`.values();
298
+ * // Returns: [["Alice", 30], ["Bob", 25]]
299
+ *
300
+ * // INSERT/UPDATE/DELETE - returns SQLiteRunResult
301
+ * const result = await sql`INSERT INTO users (name, age) VALUES (${name}, ${age})` as SQLiteRunResult;
302
+ * console.log('Inserted row:', result.lastInsertRowId);
303
+ *
304
+ * // Iteration
305
+ * for await (const user of db<User>`SELECT * FROM users`.each()) {
306
+ * console.log(user.name);
307
+ * }
308
+ *
309
+ * // Synchronous API
310
+ * const users = sql<User>`SELECT * FROM users WHERE age > ${21}`.allSync();
311
+ * const user = sql<User>`SELECT * FROM users WHERE id = ${userId}`.firstSync();
312
+ * ```
313
+ */
314
+ sql = (strings, ...values) => new SQLiteTaggedQuery(this, strings, values);
280
315
  async runAsync(source, ...params) {
281
316
  const statement = await this.prepareAsync(source);
282
317
  let result;
@@ -1 +1 @@
1
- {"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ACvC,QAA8C;IAE9C,OAAO,UAAU,CAAC,WAAW,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC;AAED;;;GAGG;AACH,MAAM,WAAY,SAAQ,cAAc;IAC/B,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,EAAkB;QAChD,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC;QAC1D,MAAM,cAAc,GAAG,IAAI,UAAU,CAAC,cAAc,CAClD,EAAE,CAAC,YAAY,EACf,kBAAkB,CAAC,OAAO,CAAC,CAC5B,CAAC;QACF,MAAM,cAAc,CAAC,SAAS,EAAE,CAAC;QACjC,OAAO,IAAI,WAAW,CAAC,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;IACnE,CAAC;CACF","sourcesContent":["import { type EventSubscription } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nimport ExpoSQLite from './ExpoSQLite';\nimport { flattenOpenOptions, NativeDatabase, SQLiteOpenOptions } from './NativeDatabase';\nimport {\n registerDatabaseForDevToolsAsync,\n unregisterDatabaseForDevToolsAsync,\n} from './SQLiteDevToolsClient';\nimport { SQLiteSession } from './SQLiteSession';\nimport {\n SQLiteBindParams,\n SQLiteExecuteAsyncResult,\n SQLiteExecuteSyncResult,\n SQLiteRunResult,\n SQLiteStatement,\n SQLiteVariadicBindParams,\n} from './SQLiteStatement';\nimport { createDatabasePath } from './pathUtils';\n\nexport { SQLiteOpenOptions };\n\n/**\n * A SQLite database.\n */\nexport class SQLiteDatabase {\n constructor(\n public readonly databasePath: string,\n public readonly options: SQLiteOpenOptions,\n public 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 if (this.options.useNewConnection !== true) {\n unregisterDatabaseForDevToolsAsync(this);\n }\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 * [Serialize the database](https://sqlite.org/c3ref/serialize.html) as `Uint8Array`.\n *\n * @param databaseName The name of the current attached databases. The default value is `main` which is the default database name.\n */\n public serializeAsync(databaseName: string = 'main'): Promise<Uint8Array> {\n return this.nativeDatabase.serializeAsync(databaseName);\n }\n\n /**\n * Create a [prepared SQLite statement](https://www.sqlite.org/c3ref/prepare.html).\n *\n * @param source A string containing the SQL query.\n */\n public async prepareAsync(source: string): Promise<SQLiteStatement> {\n const nativeStatement = new ExpoSQLite.NativeStatement();\n await this.nativeDatabase.prepareAsync(nativeStatement, source);\n return new SQLiteStatement(this.nativeDatabase, nativeStatement);\n }\n\n /**\n * Create a new session for the database.\n * @see [`sqlite3session_create`](https://www.sqlite.org/session/sqlite3session_create.html)\n * @param dbName The name of the database to create a session for. The default value is `main`.\n */\n public async createSessionAsync(dbName: string = 'main'): Promise<SQLiteSession> {\n const nativeSession = new ExpoSQLite.NativeSession();\n await this.nativeDatabase.createSessionAsync(nativeSession, dbName);\n return new SQLiteSession(this.nativeDatabase, nativeSession);\n }\n\n /**\n * Load a SQLite extension.\n * @param libPath The path to the extension library file.\n * @param entryPoint The entry point of the extension. If not provided, the default entry point is inferred by [`sqlite3_load_extension`](https://www.sqlite.org/c3ref/load_extension.html).\n *\n * @platform android\n * @platform ios\n * @platform macos\n * @platform tvos\n *\n * @example\n * ```ts\n * // Load `sqlite-vec` from `bundledExtensions`. You need to enable `withSQLiteVecExtension` to include `sqlite-vec`.\n * const extension = SQLite.bundledExtensions['sqlite-vec'];\n * await db.loadExtensionAsync(extension.libPath, extension.entryPoint);\n *\n * // You can also load a custom extension.\n * await db.loadExtensionAsync('/path/to/extension');\n * ```\n */\n public loadExtensionAsync(libPath: string, entryPoint?: string): Promise<void> {\n return this.nativeDatabase.loadExtensionAsync(libPath, entryPoint);\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 *\n * @example\n * ```ts\n * db.withTransactionAsync(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.getFirstAsync<{ 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 `withExclusiveTransactionAsync` instead.\n *\n * @param task An async function to execute within a transaction.\n */\n public async withTransactionAsync(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 * > **Note:** This function is not supported on web.\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 [`SQLiteDatabase`](#sqlitedatabase) object. You can use `txn` like a [`SQLiteDatabase`](#sqlitedatabase) object.\n *\n * @platform android\n * @platform ios\n * @platform macos\n * @platform tvos\n *\n * @example\n * ```ts\n * db.withExclusiveTransactionAsync(async (txn) => {\n * await txn.execAsync('UPDATE test SET name = \"aaa\"');\n * });\n * ```\n */\n public async withExclusiveTransactionAsync(\n task: (txn: Transaction) => Promise<void>\n ): Promise<void> {\n if (Platform.OS === 'web') {\n throw new Error('withExclusiveTransactionAsync is not supported on web');\n }\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 if (this.options.useNewConnection !== true) {\n unregisterDatabaseForDevToolsAsync(this);\n }\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 * [Serialize the database](https://sqlite.org/c3ref/serialize.html) as `Uint8Array`.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param databaseName The name of the current attached databases. The default value is `main` which is the default database name.\n */\n public serializeSync(databaseName: string = 'main'): Uint8Array {\n return this.nativeDatabase.serializeSync(databaseName);\n }\n\n /**\n * Create a [prepared SQLite statement](https://www.sqlite.org/c3ref/prepare.html).\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): SQLiteStatement {\n const nativeStatement = new ExpoSQLite.NativeStatement();\n this.nativeDatabase.prepareSync(nativeStatement, source);\n return new SQLiteStatement(this.nativeDatabase, nativeStatement);\n }\n\n /**\n * Create a new session for the database.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @see [`sqlite3session_create`](https://www.sqlite.org/session/sqlite3session_create.html)\n * @param dbName The name of the database to create a session for. The default value is `main`.\n */\n public createSessionSync(dbName: string = 'main'): SQLiteSession {\n const nativeSession = new ExpoSQLite.NativeSession();\n this.nativeDatabase.createSessionSync(nativeSession, dbName);\n return new SQLiteSession(this.nativeDatabase, nativeSession);\n }\n\n /**\n * Load a SQLite extension.\n * @param libPath The path to the extension library file.\n * @param entryPoint The entry point of the extension. If not provided, the default entry point is inferred by [`sqlite3_load_extension`](https://www.sqlite.org/c3ref/load_extension.html).\n *\n * @platform android\n * @platform ios\n * @platform macos\n * @platform tvos\n *\n * @example\n * ```ts\n * // Load `sqlite-vec` from `bundledExtensions`. You need to enable `withSQLiteVecExtension` to include `sqlite-vec`.\n * const extension = SQLite.bundledExtensions['sqlite-vec'];\n * db.loadExtensionSync(extension.libPath, extension.entryPoint);\n *\n * // You can also load a custom extension.\n * db.loadExtensionSync('/path/to/extension');\n * ```\n\n */\n public loadExtensionSync(libPath: string, entryPoint?: string): void {\n this.nativeDatabase.loadExtensionSync(libPath, entryPoint);\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 withTransactionSync(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 * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).\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 [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public runAsync(source: string, params: SQLiteBindParams): Promise<SQLiteRunResult>;\n\n /**\n * @hidden\n */\n public runAsync(source: string, ...params: SQLiteVariadicBindParams): Promise<SQLiteRunResult>;\n public async runAsync(source: string, ...params: any[]): Promise<SQLiteRunResult> {\n const statement = await this.prepareAsync(source);\n let result: SQLiteExecuteAsyncResult<unknown>;\n try {\n result = await statement.executeAsync(...params);\n } finally {\n await statement.finalizeAsync();\n }\n return result;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), [`SQLiteExecuteAsyncResult.getFirstAsync()`](#getfirstasync), and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).\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 [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public getFirstAsync<T>(source: string, params: SQLiteBindParams): Promise<T | null>;\n /**\n * @hidden\n */\n public getFirstAsync<T>(source: string, ...params: SQLiteVariadicBindParams): Promise<T | null>;\n public async getFirstAsync<T>(source: string, ...params: any[]): Promise<T | null> {\n const statement = await this.prepareAsync(source);\n let firstRow: T | null;\n try {\n const result = await statement.executeAsync<T>(...params);\n firstRow = await result.getFirstAsync();\n } finally {\n await statement.finalizeAsync();\n }\n return firstRow;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), [`SQLiteExecuteAsyncResult`](#sqliteexecuteasyncresult) `AsyncIterator`, and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).\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 [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n * @returns Rather than returning Promise, this function returns an [`AsyncIterableIterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator). You can use `for await...of` to iterate over the rows from the SQLite query result.\n */\n public getEachAsync<T>(source: string, params: SQLiteBindParams): AsyncIterableIterator<T>;\n /**\n * @hidden\n */\n public getEachAsync<T>(\n source: string,\n ...params: SQLiteVariadicBindParams\n ): AsyncIterableIterator<T>;\n public async *getEachAsync<T>(source: string, ...params: any[]): AsyncIterableIterator<T> {\n const statement = await this.prepareAsync(source);\n try {\n const result = await statement.executeAsync<T>(...params);\n for await (const row of result) {\n yield row;\n }\n } finally {\n await statement.finalizeAsync();\n }\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), [`SQLiteExecuteAsyncResult.getAllAsync()`](#getallasync), and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).\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 [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n * @example\n * ```ts\n * // For unnamed parameters, you pass values in an array.\n * db.getAllAsync('SELECT * FROM test WHERE intValue = ? AND name = ?', [1, 'Hello']);\n *\n * // For unnamed parameters, you pass values in variadic arguments.\n * db.getAllAsync('SELECT * FROM test WHERE intValue = ? AND name = ?', 1, 'Hello');\n *\n * // For named parameters, you should pass values in object.\n * db.getAllAsync('SELECT * FROM test WHERE intValue = $intValue AND name = $name', { $intValue: 1, $name: 'Hello' });\n * ```\n */\n public getAllAsync<T>(source: string, params: SQLiteBindParams): Promise<T[]>;\n /**\n * @hidden\n */\n public getAllAsync<T>(source: string, ...params: SQLiteVariadicBindParams): Promise<T[]>;\n public async getAllAsync<T>(source: string, ...params: any[]): Promise<T[]> {\n const statement = await this.prepareAsync(source);\n let allRows;\n try {\n const result = await statement.executeAsync<T>(...params);\n allRows = await result.getAllAsync();\n } finally {\n await statement.finalizeAsync();\n }\n return allRows;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareSync()`](#preparesyncsource), [`SQLiteStatement.executeSync()`](#executesyncparams), and [`SQLiteStatement.finalizeSync()`](#finalizesync).\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 [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public runSync(source: string, params: SQLiteBindParams): SQLiteRunResult;\n /**\n * @hidden\n */\n public runSync(source: string, ...params: SQLiteVariadicBindParams): SQLiteRunResult;\n public runSync(source: string, ...params: any[]): SQLiteRunResult {\n const statement = this.prepareSync(source);\n let result: SQLiteExecuteSyncResult<unknown>;\n try {\n result = statement.executeSync(...params);\n } finally {\n statement.finalizeSync();\n }\n return result;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareSync()`](#preparesyncsource), [`SQLiteStatement.executeSync()`](#executesyncparams), [`SQLiteExecuteSyncResult.getFirstSync()`](#getfirstsync), and [`SQLiteStatement.finalizeSync()`](#finalizesync).\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 [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public getFirstSync<T>(source: string, params: SQLiteBindParams): T | null;\n /**\n * @hidden\n */\n public getFirstSync<T>(source: string, ...params: SQLiteVariadicBindParams): T | null;\n public getFirstSync<T>(source: string, ...params: any[]): T | null {\n const statement = this.prepareSync(source);\n let firstRow: T | null;\n try {\n const result = statement.executeSync<T>(...params);\n firstRow = result.getFirstSync();\n } finally {\n statement.finalizeSync();\n }\n return firstRow;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareSync()`](#preparesyncsource), [`SQLiteStatement.executeSync()`](#executesyncparams), [`SQLiteExecuteSyncResult`](#sqliteexecutesyncresult) `Iterator`, and [`SQLiteStatement.finalizeSync()`](#finalizesync).\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 [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n * @returns This function returns an [`IterableIterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator). You can use `for...of` to iterate over the rows from the SQLite query result.\n */\n public getEachSync<T>(source: string, params: SQLiteBindParams): IterableIterator<T>;\n /**\n * @hidden\n */\n public getEachSync<T>(source: string, ...params: SQLiteVariadicBindParams): IterableIterator<T>;\n public *getEachSync<T>(source: string, ...params: any[]): IterableIterator<T> {\n const statement = this.prepareSync(source);\n try {\n const result = statement.executeSync<T>(...params);\n for (const row of result) {\n yield row;\n }\n } finally {\n statement.finalizeSync();\n }\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareSync()`](#preparesyncsource), [`SQLiteStatement.executeSync()`](#executesyncparams), [`SQLiteExecuteSyncResult.getAllSync()`](#getallsync), and [`SQLiteStatement.finalizeSync()`](#finalizesync).\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 [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public getAllSync<T>(source: string, params: SQLiteBindParams): T[];\n /**\n * @hidden\n */\n public getAllSync<T>(source: string, ...params: SQLiteVariadicBindParams): T[];\n public getAllSync<T>(source: string, ...params: any[]): T[] {\n const statement = this.prepareSync(source);\n let allRows;\n try {\n const result = statement.executeSync<T>(...params);\n allRows = result.getAllSync();\n } finally {\n statement.finalizeSync();\n }\n return allRows;\n }\n\n /**\n * Synchronize the local database with the remote libSQL server.\n * This method is only available from libSQL integration.\n */\n public syncLibSQL(): Promise<void> {\n if (typeof this.nativeDatabase.syncLibSQL !== 'function') {\n throw new Error('syncLibSQL is not supported in the current environment');\n }\n return this.nativeDatabase.syncLibSQL();\n }\n\n //#endregion\n}\n\n/**\n * The default directory for SQLite databases.\n */\nexport const defaultDatabaseDirectory = ExpoSQLite.defaultDatabaseDirectory;\n\n/**\n * The pre-bundled SQLite extensions.\n */\nexport const bundledExtensions: Record<\n string,\n { libPath: string; entryPoint: string } | undefined\n> = ExpoSQLite.bundledExtensions;\n\n/**\n * Open a database.\n *\n * @param databaseName The name of the database file to open.\n * @param options Open options.\n * @param directory The directory where the database file is located. The default value is `defaultDatabaseDirectory`. This parameter is not supported on web.\n */\nexport async function openDatabaseAsync(\n databaseName: string,\n options?: SQLiteOpenOptions,\n directory?: string\n): Promise<SQLiteDatabase> {\n const openOptions = options ?? {};\n const databasePath = createDatabasePath(databaseName, directory);\n await ExpoSQLite.ensureDatabasePathExistsAsync(databasePath);\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n databasePath,\n flattenOpenOptions(openOptions)\n );\n await nativeDatabase.initAsync();\n const database = new SQLiteDatabase(databasePath, openOptions, nativeDatabase);\n if (options?.useNewConnection !== true) {\n registerDatabaseForDevToolsAsync(database);\n }\n return database;\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 databaseName The name of the database file to open.\n * @param options Open options.\n * @param directory The directory where the database file is located. The default value is `defaultDatabaseDirectory`. This parameter is not supported on web.\n */\nexport function openDatabaseSync(\n databaseName: string,\n options?: SQLiteOpenOptions,\n directory?: string\n): SQLiteDatabase {\n const openOptions = options ?? {};\n const databasePath = createDatabasePath(databaseName, directory);\n ExpoSQLite.ensureDatabasePathExistsSync(databasePath);\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n databasePath,\n flattenOpenOptions(openOptions)\n );\n nativeDatabase.initSync();\n const database = new SQLiteDatabase(databasePath, openOptions, nativeDatabase);\n if (options?.useNewConnection !== true) {\n registerDatabaseForDevToolsAsync(database);\n }\n return database;\n}\n\n/**\n * Given a `Uint8Array` data and [deserialize to memory database](https://sqlite.org/c3ref/deserialize.html).\n *\n * @param serializedData The binary array to deserialize from [`SQLiteDatabase.serializeAsync()`](#serializeasyncdatabasename).\n * @param options Open options.\n */\nexport async function deserializeDatabaseAsync(\n serializedData: Uint8Array,\n options?: SQLiteOpenOptions\n): Promise<SQLiteDatabase> {\n const openOptions = options ?? {};\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n ':memory:',\n flattenOpenOptions(openOptions),\n serializedData\n );\n await nativeDatabase.initAsync();\n return new SQLiteDatabase(':memory:', openOptions, nativeDatabase);\n}\n\n/**\n * Given a `Uint8Array` data and [deserialize to memory database](https://sqlite.org/c3ref/deserialize.html).\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param serializedData The binary array to deserialize from [`SQLiteDatabase.serializeSync()`](#serializesyncdatabasename)\n * @param options Open options.\n */\nexport function deserializeDatabaseSync(\n serializedData: Uint8Array,\n options?: SQLiteOpenOptions\n): SQLiteDatabase {\n const openOptions = options ?? {};\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n ':memory:',\n flattenOpenOptions(openOptions),\n serializedData\n );\n nativeDatabase.initSync();\n return new SQLiteDatabase(':memory:', openOptions, nativeDatabase);\n}\n\n/**\n * Delete a database file.\n *\n * @param databaseName The name of the database file to delete.\n * @param directory The directory where the database file is located. The default value is `defaultDatabaseDirectory`.\n */\nexport async function deleteDatabaseAsync(databaseName: string, directory?: string): Promise<void> {\n const databasePath = createDatabasePath(databaseName, directory);\n return await ExpoSQLite.deleteDatabaseAsync(databasePath);\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 databaseName The name of the database file to delete.\n * @param directory The directory where the database file is located. The default value is `defaultDatabaseDirectory`.\n */\nexport function deleteDatabaseSync(databaseName: string, directory?: string): void {\n const databasePath = createDatabasePath(databaseName, directory);\n return ExpoSQLite.deleteDatabaseSync(databasePath);\n}\n\n/**\n * Backup a database to another database.\n *\n * @see https://www.sqlite.org/c3ref/backup_finish.html\n *\n * @param options - The backup options\n * @param options.sourceDatabase - The source database to backup from\n * @param options.sourceDatabaseName - The name of the source database. The default value is `main`\n * @param options.destDatabase - The destination database to backup to\n * @param options.destDatabaseName - The name of the destination database. The default value is `m\n */\nexport function backupDatabaseAsync({\n sourceDatabase,\n sourceDatabaseName,\n destDatabase,\n destDatabaseName,\n}: {\n sourceDatabase: SQLiteDatabase;\n sourceDatabaseName?: string;\n destDatabase: SQLiteDatabase;\n destDatabaseName?: string;\n}): Promise<void> {\n return ExpoSQLite.backupDatabaseAsync(\n destDatabase.nativeDatabase,\n destDatabaseName ?? 'main',\n sourceDatabase.nativeDatabase,\n sourceDatabaseName ?? 'main'\n );\n}\n\n/**\n * Backup a database to another database.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @see https://www.sqlite.org/c3ref/backup_finish.html\n *\n * @param options - The backup options\n * @param options.sourceDatabase - The source database to backup from\n * @param options.sourceDatabaseName - The name of the source database. The default value is `main`\n * @param options.destDatabase - The destination database to backup to\n * @param options.destDatabaseName - The name of the destination database. The default value is `m\n */\nexport function backupDatabaseSync({\n sourceDatabase,\n sourceDatabaseName,\n destDatabase,\n destDatabaseName,\n}: {\n sourceDatabase: SQLiteDatabase;\n sourceDatabaseName?: string;\n destDatabase: SQLiteDatabase;\n destDatabaseName?: string;\n}): void {\n return ExpoSQLite.backupDatabaseSync(\n destDatabase.nativeDatabase,\n destDatabaseName ?? 'main',\n sourceDatabase.nativeDatabase,\n sourceDatabaseName ?? 'main'\n );\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 databaseName: string;\n\n /** The absolute file path to the database. */\n databaseFilePath: 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`](#sqliteopenoptions) when opening the database.\n *\n * @param listener A function that receives the `databaseName`, `databaseFilePath`, `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): EventSubscription {\n return ExpoSQLite.addListener('onDatabaseChange', listener);\n}\n\n/**\n * A new connection specific used for [`withExclusiveTransactionAsync`](#withexclusivetransactionasynctask).\n * @hidden not going to pull all the database methods to the document.\n */\nclass Transaction extends SQLiteDatabase {\n public static async createAsync(db: SQLiteDatabase): Promise<Transaction> {\n const options = { ...db.options, useNewConnection: true };\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n db.databasePath,\n flattenOpenOptions(options)\n );\n await nativeDatabase.initAsync();\n return new Transaction(db.databasePath, options, nativeDatabase);\n }\n}\n"]}
1
+ {"version":3,"file":"SQLiteDatabase.js","sourceRoot":"","sources":["../src/SQLiteDatabase.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAqC,MAAM,kBAAkB,CAAC;AACzF,OAAO,EACL,gCAAgC,EAChC,kCAAkC,GACnC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAKL,eAAe,GAEhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAIjD;;GAEG;AACH,MAAM,OAAO,cAAc;IAEP;IACA;IACA;IAHlB,YACkB,YAAoB,EACpB,OAA0B,EAC1B,cAA8B;QAF9B,iBAAY,GAAZ,YAAY,CAAQ;QACpB,YAAO,GAAP,OAAO,CAAmB;QAC1B,mBAAc,GAAd,cAAc,CAAgB;IAC7C,CAAC;IAEJ;;OAEG;IACI,oBAAoB;QACzB,OAAO,IAAI,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;IACpD,CAAC;IAED;;OAEG;IACI,UAAU;QACf,IAAI,IAAI,CAAC,OAAO,CAAC,gBAAgB,KAAK,IAAI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AED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,GAMjB;IACC,OAAO,UAAU,CAAC,mBAAmB,CACnC,YAAY,CAAC,cAAc,EAC3B,gBAAgB,IAAI,MAAM,EAC1B,cAAc,CAAC,cAAc,EAC7B,kBAAkB,IAAI,MAAM,CAC7B,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,kBAAkB,CAAC,EACjC,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,GAMjB;IACC,OAAO,UAAU,CAAC,kBAAkB,CAClC,YAAY,CAAC,cAAc,EAC3B,gBAAgB,IAAI,MAAM,EAC1B,cAAc,CAAC,cAAc,EAC7B,kBAAkB,IAAI,MAAM,CAC7B,CAAC;AACJ,CAAC;AAmBD;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAA8C;IAE9C,OAAO,UAAU,CAAC,WAAW,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC;AAED;;;GAGG;AACH,MAAM,WAAY,SAAQ,cAAc;IAC/B,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,EAAkB;QAChD,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC;QAC1D,MAAM,cAAc,GAAG,IAAI,UAAU,CAAC,cAAc,CAClD,EAAE,CAAC,YAAY,EACf,kBAAkB,CAAC,OAAO,CAAC,CAC5B,CAAC;QACF,MAAM,cAAc,CAAC,SAAS,EAAE,CAAC;QACjC,OAAO,IAAI,WAAW,CAAC,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;IACnE,CAAC;CACF","sourcesContent":["import { type EventSubscription } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nimport ExpoSQLite from './ExpoSQLite';\nimport { flattenOpenOptions, NativeDatabase, SQLiteOpenOptions } from './NativeDatabase';\nimport {\n registerDatabaseForDevToolsAsync,\n unregisterDatabaseForDevToolsAsync,\n} from './SQLiteDevToolsClient';\nimport { SQLiteSession } from './SQLiteSession';\nimport {\n SQLiteBindParams,\n SQLiteExecuteAsyncResult,\n SQLiteExecuteSyncResult,\n SQLiteRunResult,\n SQLiteStatement,\n SQLiteVariadicBindParams,\n} from './SQLiteStatement';\nimport { SQLiteTaggedQuery } from './SQLiteTaggedQuery';\nimport { createDatabasePath } from './pathUtils';\n\nexport { SQLiteOpenOptions };\n\n/**\n * A SQLite database.\n */\nexport class SQLiteDatabase {\n constructor(\n public readonly databasePath: string,\n public readonly options: SQLiteOpenOptions,\n public 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 if (this.options.useNewConnection !== true) {\n unregisterDatabaseForDevToolsAsync(this);\n }\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 * [Serialize the database](https://sqlite.org/c3ref/serialize.html) as `Uint8Array`.\n *\n * @param databaseName The name of the current attached databases. The default value is `main` which is the default database name.\n */\n public serializeAsync(databaseName: string = 'main'): Promise<Uint8Array> {\n return this.nativeDatabase.serializeAsync(databaseName);\n }\n\n /**\n * Create a [prepared SQLite statement](https://www.sqlite.org/c3ref/prepare.html).\n *\n * @param source A string containing the SQL query.\n */\n public async prepareAsync(source: string): Promise<SQLiteStatement> {\n const nativeStatement = new ExpoSQLite.NativeStatement();\n await this.nativeDatabase.prepareAsync(nativeStatement, source);\n return new SQLiteStatement(this.nativeDatabase, nativeStatement);\n }\n\n /**\n * Create a new session for the database.\n * @see [`sqlite3session_create`](https://www.sqlite.org/session/sqlite3session_create.html)\n * @param dbName The name of the database to create a session for. The default value is `main`.\n */\n public async createSessionAsync(dbName: string = 'main'): Promise<SQLiteSession> {\n const nativeSession = new ExpoSQLite.NativeSession();\n await this.nativeDatabase.createSessionAsync(nativeSession, dbName);\n return new SQLiteSession(this.nativeDatabase, nativeSession);\n }\n\n /**\n * Load a SQLite extension.\n * @param libPath The path to the extension library file.\n * @param entryPoint The entry point of the extension. If not provided, the default entry point is inferred by [`sqlite3_load_extension`](https://www.sqlite.org/c3ref/load_extension.html).\n *\n * @platform android\n * @platform ios\n * @platform macos\n * @platform tvos\n *\n * @example\n * ```ts\n * // Load `sqlite-vec` from `bundledExtensions`. You need to enable `withSQLiteVecExtension` to include `sqlite-vec`.\n * const extension = SQLite.bundledExtensions['sqlite-vec'];\n * await db.loadExtensionAsync(extension.libPath, extension.entryPoint);\n *\n * // You can also load a custom extension.\n * await db.loadExtensionAsync('/path/to/extension');\n * ```\n */\n public loadExtensionAsync(libPath: string, entryPoint?: string): Promise<void> {\n return this.nativeDatabase.loadExtensionAsync(libPath, entryPoint);\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 *\n * @example\n * ```ts\n * db.withTransactionAsync(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.getFirstAsync<{ 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 `withExclusiveTransactionAsync` instead.\n *\n * @param task An async function to execute within a transaction.\n */\n public async withTransactionAsync(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 * > **Note:** This function is not supported on web.\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 [`SQLiteDatabase`](#sqlitedatabase) object. You can use `txn` like a [`SQLiteDatabase`](#sqlitedatabase) object.\n *\n * @platform android\n * @platform ios\n * @platform macos\n * @platform tvos\n *\n * @example\n * ```ts\n * db.withExclusiveTransactionAsync(async (txn) => {\n * await txn.execAsync('UPDATE test SET name = \"aaa\"');\n * });\n * ```\n */\n public async withExclusiveTransactionAsync(\n task: (txn: Transaction) => Promise<void>\n ): Promise<void> {\n if (Platform.OS === 'web') {\n throw new Error('withExclusiveTransactionAsync is not supported on web');\n }\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 if (this.options.useNewConnection !== true) {\n unregisterDatabaseForDevToolsAsync(this);\n }\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 * [Serialize the database](https://sqlite.org/c3ref/serialize.html) as `Uint8Array`.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param databaseName The name of the current attached databases. The default value is `main` which is the default database name.\n */\n public serializeSync(databaseName: string = 'main'): Uint8Array {\n return this.nativeDatabase.serializeSync(databaseName);\n }\n\n /**\n * Create a [prepared SQLite statement](https://www.sqlite.org/c3ref/prepare.html).\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): SQLiteStatement {\n const nativeStatement = new ExpoSQLite.NativeStatement();\n this.nativeDatabase.prepareSync(nativeStatement, source);\n return new SQLiteStatement(this.nativeDatabase, nativeStatement);\n }\n\n /**\n * Create a new session for the database.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @see [`sqlite3session_create`](https://www.sqlite.org/session/sqlite3session_create.html)\n * @param dbName The name of the database to create a session for. The default value is `main`.\n */\n public createSessionSync(dbName: string = 'main'): SQLiteSession {\n const nativeSession = new ExpoSQLite.NativeSession();\n this.nativeDatabase.createSessionSync(nativeSession, dbName);\n return new SQLiteSession(this.nativeDatabase, nativeSession);\n }\n\n /**\n * Load a SQLite extension.\n * @param libPath The path to the extension library file.\n * @param entryPoint The entry point of the extension. If not provided, the default entry point is inferred by [`sqlite3_load_extension`](https://www.sqlite.org/c3ref/load_extension.html).\n *\n * @platform android\n * @platform ios\n * @platform macos\n * @platform tvos\n *\n * @example\n * ```ts\n * // Load `sqlite-vec` from `bundledExtensions`. You need to enable `withSQLiteVecExtension` to include `sqlite-vec`.\n * const extension = SQLite.bundledExtensions['sqlite-vec'];\n * db.loadExtensionSync(extension.libPath, extension.entryPoint);\n *\n * // You can also load a custom extension.\n * db.loadExtensionSync('/path/to/extension');\n * ```\n\n */\n public loadExtensionSync(libPath: string, entryPoint?: string): void {\n this.nativeDatabase.loadExtensionSync(libPath, entryPoint);\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 withTransactionSync(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 /**\n * Execute SQL queries using tagged template literals (Bun-style API).\n * Queries are automatically protected against SQL injection using prepared statements.\n *\n * The query result is directly awaitable and returns an array of objects by default.\n * Use `.values()`, `.first()`, or `.each()` for different result formats.\n *\n * @example\n * ```ts\n * // Direct await - returns array of objects\n * const users = await sql<User>`SELECT * FROM users WHERE age > ${21}`;\n *\n * // Get first row only\n * const user = await sql<User>`SELECT * FROM users WHERE id = ${userId}`.first();\n *\n * // Get values as arrays\n * const rows = await sql`SELECT name, age FROM users`.values();\n * // Returns: [[\"Alice\", 30], [\"Bob\", 25]]\n *\n * // INSERT/UPDATE/DELETE - returns SQLiteRunResult\n * const result = await sql`INSERT INTO users (name, age) VALUES (${name}, ${age})` as SQLiteRunResult;\n * console.log('Inserted row:', result.lastInsertRowId);\n *\n * // Iteration\n * for await (const user of db<User>`SELECT * FROM users`.each()) {\n * console.log(user.name);\n * }\n *\n * // Synchronous API\n * const users = sql<User>`SELECT * FROM users WHERE age > ${21}`.allSync();\n * const user = sql<User>`SELECT * FROM users WHERE id = ${userId}`.firstSync();\n * ```\n */\n public sql = <T = unknown>(strings: TemplateStringsArray, ...values: unknown[]) =>\n new SQLiteTaggedQuery<T>(this, strings, values);\n\n //#region Statement API shorthands\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).\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 [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public runAsync(source: string, params: SQLiteBindParams): Promise<SQLiteRunResult>;\n\n /**\n * @hidden\n */\n public runAsync(source: string, ...params: SQLiteVariadicBindParams): Promise<SQLiteRunResult>;\n public async runAsync(source: string, ...params: any[]): Promise<SQLiteRunResult> {\n const statement = await this.prepareAsync(source);\n let result: SQLiteExecuteAsyncResult<unknown>;\n try {\n result = await statement.executeAsync(...params);\n } finally {\n await statement.finalizeAsync();\n }\n return result;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), [`SQLiteExecuteAsyncResult.getFirstAsync()`](#getfirstasync), and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).\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 [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public getFirstAsync<T>(source: string, params: SQLiteBindParams): Promise<T | null>;\n /**\n * @hidden\n */\n public getFirstAsync<T>(source: string, ...params: SQLiteVariadicBindParams): Promise<T | null>;\n public async getFirstAsync<T>(source: string, ...params: any[]): Promise<T | null> {\n const statement = await this.prepareAsync(source);\n let firstRow: T | null;\n try {\n const result = await statement.executeAsync<T>(...params);\n firstRow = await result.getFirstAsync();\n } finally {\n await statement.finalizeAsync();\n }\n return firstRow;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), [`SQLiteExecuteAsyncResult`](#sqliteexecuteasyncresult) `AsyncIterator`, and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).\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 [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n * @returns Rather than returning Promise, this function returns an [`AsyncIterableIterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator). You can use `for await...of` to iterate over the rows from the SQLite query result.\n */\n public getEachAsync<T>(source: string, params: SQLiteBindParams): AsyncIterableIterator<T>;\n /**\n * @hidden\n */\n public getEachAsync<T>(\n source: string,\n ...params: SQLiteVariadicBindParams\n ): AsyncIterableIterator<T>;\n public async *getEachAsync<T>(source: string, ...params: any[]): AsyncIterableIterator<T> {\n const statement = await this.prepareAsync(source);\n try {\n const result = await statement.executeAsync<T>(...params);\n for await (const row of result) {\n yield row;\n }\n } finally {\n await statement.finalizeAsync();\n }\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), [`SQLiteExecuteAsyncResult.getAllAsync()`](#getallasync), and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).\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 [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n * @example\n * ```ts\n * // For unnamed parameters, you pass values in an array.\n * db.getAllAsync('SELECT * FROM test WHERE intValue = ? AND name = ?', [1, 'Hello']);\n *\n * // For unnamed parameters, you pass values in variadic arguments.\n * db.getAllAsync('SELECT * FROM test WHERE intValue = ? AND name = ?', 1, 'Hello');\n *\n * // For named parameters, you should pass values in object.\n * db.getAllAsync('SELECT * FROM test WHERE intValue = $intValue AND name = $name', { $intValue: 1, $name: 'Hello' });\n * ```\n */\n public getAllAsync<T>(source: string, params: SQLiteBindParams): Promise<T[]>;\n /**\n * @hidden\n */\n public getAllAsync<T>(source: string, ...params: SQLiteVariadicBindParams): Promise<T[]>;\n public async getAllAsync<T>(source: string, ...params: any[]): Promise<T[]> {\n const statement = await this.prepareAsync(source);\n let allRows;\n try {\n const result = await statement.executeAsync<T>(...params);\n allRows = await result.getAllAsync();\n } finally {\n await statement.finalizeAsync();\n }\n return allRows;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareSync()`](#preparesyncsource), [`SQLiteStatement.executeSync()`](#executesyncparams), and [`SQLiteStatement.finalizeSync()`](#finalizesync).\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 [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public runSync(source: string, params: SQLiteBindParams): SQLiteRunResult;\n /**\n * @hidden\n */\n public runSync(source: string, ...params: SQLiteVariadicBindParams): SQLiteRunResult;\n public runSync(source: string, ...params: any[]): SQLiteRunResult {\n const statement = this.prepareSync(source);\n let result: SQLiteExecuteSyncResult<unknown>;\n try {\n result = statement.executeSync(...params);\n } finally {\n statement.finalizeSync();\n }\n return result;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareSync()`](#preparesyncsource), [`SQLiteStatement.executeSync()`](#executesyncparams), [`SQLiteExecuteSyncResult.getFirstSync()`](#getfirstsync), and [`SQLiteStatement.finalizeSync()`](#finalizesync).\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 [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public getFirstSync<T>(source: string, params: SQLiteBindParams): T | null;\n /**\n * @hidden\n */\n public getFirstSync<T>(source: string, ...params: SQLiteVariadicBindParams): T | null;\n public getFirstSync<T>(source: string, ...params: any[]): T | null {\n const statement = this.prepareSync(source);\n let firstRow: T | null;\n try {\n const result = statement.executeSync<T>(...params);\n firstRow = result.getFirstSync();\n } finally {\n statement.finalizeSync();\n }\n return firstRow;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareSync()`](#preparesyncsource), [`SQLiteStatement.executeSync()`](#executesyncparams), [`SQLiteExecuteSyncResult`](#sqliteexecutesyncresult) `Iterator`, and [`SQLiteStatement.finalizeSync()`](#finalizesync).\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 [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n * @returns This function returns an [`IterableIterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator). You can use `for...of` to iterate over the rows from the SQLite query result.\n */\n public getEachSync<T>(source: string, params: SQLiteBindParams): IterableIterator<T>;\n /**\n * @hidden\n */\n public getEachSync<T>(source: string, ...params: SQLiteVariadicBindParams): IterableIterator<T>;\n public *getEachSync<T>(source: string, ...params: any[]): IterableIterator<T> {\n const statement = this.prepareSync(source);\n try {\n const result = statement.executeSync<T>(...params);\n for (const row of result) {\n yield row;\n }\n } finally {\n statement.finalizeSync();\n }\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareSync()`](#preparesyncsource), [`SQLiteStatement.executeSync()`](#executesyncparams), [`SQLiteExecuteSyncResult.getAllSync()`](#getallsync), and [`SQLiteStatement.finalizeSync()`](#finalizesync).\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 [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public getAllSync<T>(source: string, params: SQLiteBindParams): T[];\n /**\n * @hidden\n */\n public getAllSync<T>(source: string, ...params: SQLiteVariadicBindParams): T[];\n public getAllSync<T>(source: string, ...params: any[]): T[] {\n const statement = this.prepareSync(source);\n let allRows;\n try {\n const result = statement.executeSync<T>(...params);\n allRows = result.getAllSync();\n } finally {\n statement.finalizeSync();\n }\n return allRows;\n }\n\n /**\n * Synchronize the local database with the remote libSQL server.\n * This method is only available from libSQL integration.\n */\n public syncLibSQL(): Promise<void> {\n if (typeof this.nativeDatabase.syncLibSQL !== 'function') {\n throw new Error('syncLibSQL is not supported in the current environment');\n }\n return this.nativeDatabase.syncLibSQL();\n }\n\n //#endregion\n}\n\n/**\n * The default directory for SQLite databases.\n */\nexport const defaultDatabaseDirectory = ExpoSQLite.defaultDatabaseDirectory;\n\n/**\n * The pre-bundled SQLite extensions.\n */\nexport const bundledExtensions: Record<\n string,\n { libPath: string; entryPoint: string } | undefined\n> = ExpoSQLite.bundledExtensions;\n\n/**\n * Open a database.\n *\n * @param databaseName The name of the database file to open.\n * @param options Open options.\n * @param directory The directory where the database file is located. The default value is `defaultDatabaseDirectory`. This parameter is not supported on web.\n */\nexport async function openDatabaseAsync(\n databaseName: string,\n options?: SQLiteOpenOptions,\n directory?: string\n): Promise<SQLiteDatabase> {\n const openOptions = options ?? {};\n const databasePath = createDatabasePath(databaseName, directory);\n await ExpoSQLite.ensureDatabasePathExistsAsync(databasePath);\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n databasePath,\n flattenOpenOptions(openOptions)\n );\n await nativeDatabase.initAsync();\n const database = new SQLiteDatabase(databasePath, openOptions, nativeDatabase);\n if (options?.useNewConnection !== true) {\n registerDatabaseForDevToolsAsync(database);\n }\n return database;\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 databaseName The name of the database file to open.\n * @param options Open options.\n * @param directory The directory where the database file is located. The default value is `defaultDatabaseDirectory`. This parameter is not supported on web.\n */\nexport function openDatabaseSync(\n databaseName: string,\n options?: SQLiteOpenOptions,\n directory?: string\n): SQLiteDatabase {\n const openOptions = options ?? {};\n const databasePath = createDatabasePath(databaseName, directory);\n ExpoSQLite.ensureDatabasePathExistsSync(databasePath);\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n databasePath,\n flattenOpenOptions(openOptions)\n );\n nativeDatabase.initSync();\n const database = new SQLiteDatabase(databasePath, openOptions, nativeDatabase);\n if (options?.useNewConnection !== true) {\n registerDatabaseForDevToolsAsync(database);\n }\n return database;\n}\n\n/**\n * Given a `Uint8Array` data and [deserialize to memory database](https://sqlite.org/c3ref/deserialize.html).\n *\n * @param serializedData The binary array to deserialize from [`SQLiteDatabase.serializeAsync()`](#serializeasyncdatabasename).\n * @param options Open options.\n */\nexport async function deserializeDatabaseAsync(\n serializedData: Uint8Array,\n options?: SQLiteOpenOptions\n): Promise<SQLiteDatabase> {\n const openOptions = options ?? {};\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n ':memory:',\n flattenOpenOptions(openOptions),\n serializedData\n );\n await nativeDatabase.initAsync();\n return new SQLiteDatabase(':memory:', openOptions, nativeDatabase);\n}\n\n/**\n * Given a `Uint8Array` data and [deserialize to memory database](https://sqlite.org/c3ref/deserialize.html).\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param serializedData The binary array to deserialize from [`SQLiteDatabase.serializeSync()`](#serializesyncdatabasename)\n * @param options Open options.\n */\nexport function deserializeDatabaseSync(\n serializedData: Uint8Array,\n options?: SQLiteOpenOptions\n): SQLiteDatabase {\n const openOptions = options ?? {};\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n ':memory:',\n flattenOpenOptions(openOptions),\n serializedData\n );\n nativeDatabase.initSync();\n return new SQLiteDatabase(':memory:', openOptions, nativeDatabase);\n}\n\n/**\n * Delete a database file.\n *\n * @param databaseName The name of the database file to delete.\n * @param directory The directory where the database file is located. The default value is `defaultDatabaseDirectory`.\n */\nexport async function deleteDatabaseAsync(databaseName: string, directory?: string): Promise<void> {\n const databasePath = createDatabasePath(databaseName, directory);\n return await ExpoSQLite.deleteDatabaseAsync(databasePath);\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 databaseName The name of the database file to delete.\n * @param directory The directory where the database file is located. The default value is `defaultDatabaseDirectory`.\n */\nexport function deleteDatabaseSync(databaseName: string, directory?: string): void {\n const databasePath = createDatabasePath(databaseName, directory);\n return ExpoSQLite.deleteDatabaseSync(databasePath);\n}\n\n/**\n * Backup a database to another database.\n *\n * @see https://www.sqlite.org/c3ref/backup_finish.html\n *\n * @param options - The backup options\n * @param options.sourceDatabase - The source database to backup from\n * @param options.sourceDatabaseName - The name of the source database. The default value is `main`\n * @param options.destDatabase - The destination database to backup to\n * @param options.destDatabaseName - The name of the destination database. The default value is `m\n */\nexport function backupDatabaseAsync({\n sourceDatabase,\n sourceDatabaseName,\n destDatabase,\n destDatabaseName,\n}: {\n sourceDatabase: SQLiteDatabase;\n sourceDatabaseName?: string;\n destDatabase: SQLiteDatabase;\n destDatabaseName?: string;\n}): Promise<void> {\n return ExpoSQLite.backupDatabaseAsync(\n destDatabase.nativeDatabase,\n destDatabaseName ?? 'main',\n sourceDatabase.nativeDatabase,\n sourceDatabaseName ?? 'main'\n );\n}\n\n/**\n * Backup a database to another database.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @see https://www.sqlite.org/c3ref/backup_finish.html\n *\n * @param options - The backup options\n * @param options.sourceDatabase - The source database to backup from\n * @param options.sourceDatabaseName - The name of the source database. The default value is `main`\n * @param options.destDatabase - The destination database to backup to\n * @param options.destDatabaseName - The name of the destination database. The default value is `m\n */\nexport function backupDatabaseSync({\n sourceDatabase,\n sourceDatabaseName,\n destDatabase,\n destDatabaseName,\n}: {\n sourceDatabase: SQLiteDatabase;\n sourceDatabaseName?: string;\n destDatabase: SQLiteDatabase;\n destDatabaseName?: string;\n}): void {\n return ExpoSQLite.backupDatabaseSync(\n destDatabase.nativeDatabase,\n destDatabaseName ?? 'main',\n sourceDatabase.nativeDatabase,\n sourceDatabaseName ?? 'main'\n );\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 databaseName: string;\n\n /** The absolute file path to the database. */\n databaseFilePath: 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`](#sqliteopenoptions) when opening the database.\n *\n * @param listener A function that receives the `databaseName`, `databaseFilePath`, `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): EventSubscription {\n return ExpoSQLite.addListener('onDatabaseChange', listener);\n}\n\n/**\n * A new connection specific used for [`withExclusiveTransactionAsync`](#withexclusivetransactionasynctask).\n * @hidden not going to pull all the database methods to the document.\n */\nclass Transaction extends SQLiteDatabase {\n public static async createAsync(db: SQLiteDatabase): Promise<Transaction> {\n const options = { ...db.options, useNewConnection: true };\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n db.databasePath,\n flattenOpenOptions(options)\n );\n await nativeDatabase.initAsync();\n return new Transaction(db.databasePath, options, nativeDatabase);\n }\n}\n"]}
@@ -0,0 +1,116 @@
1
+ import { SQLiteRunResult } from './NativeStatement';
2
+ import { SQLiteDatabase } from './SQLiteDatabase';
3
+ /**
4
+ * Conditional type that returns `T[]` when type parameter is explicitly provided,
5
+ * or union type when using the default `unknown` type.
6
+ */
7
+ type SQLiteTaggedQueryResult<T> = [unknown] extends [T] ? unknown[] | SQLiteRunResult : T[];
8
+ /**
9
+ * A SQL query with tagged template literals API that can be awaited directly (returns array of objects by default),
10
+ * or transformed using .values() or .first() methods.
11
+ *
12
+ * This API is inspired by Bun's SQL interface:
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * // Default: returns array of objects
17
+ * const users = await sql`SELECT * FROM users WHERE age > ${21}`;
18
+ *
19
+ * // Get values as arrays
20
+ * const values = await sql`SELECT name, age FROM users`.values();
21
+ * // Returns: [["Alice", 30], ["Bob", 25]]
22
+ *
23
+ * // Get first row only
24
+ * const user = await sql`SELECT * FROM users WHERE id = ${1}`.first();
25
+ *
26
+ * // With type parameter
27
+ * const users = await sql<User>`SELECT * FROM users`;
28
+ *
29
+ * // Mutable queries return SQLiteRunResult
30
+ * const result = await sql`INSERT INTO users (name) VALUES (${"Alice"})` as SQLiteRunResult;
31
+ * console.log(result.lastInsertRowId, result.changes);
32
+ *
33
+ * // Synchronous API
34
+ * const users = sql<User>`SELECT * FROM users WHERE age > ${21}`.allSync();
35
+ * const user = sql<User>`SELECT * FROM users WHERE id = ${userId}`.firstSync();
36
+ * ```
37
+ */
38
+ export declare class SQLiteTaggedQuery<T = unknown> implements PromiseLike<SQLiteTaggedQueryResult<T>> {
39
+ private readonly database;
40
+ private readonly source;
41
+ private readonly params;
42
+ private readonly parsedInfo;
43
+ constructor(database: SQLiteDatabase, strings: TemplateStringsArray, values: unknown[]);
44
+ /**
45
+ * Make a query awaitable that automatically returns rows or metadata based on query type.
46
+ * This is called automatically when you await the query.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * // SELECT returns array of objects
51
+ * const users = await sql`SELECT * FROM users`;
52
+ *
53
+ * // INSERT returns metadata
54
+ * const result = await sql`INSERT INTO users (name) VALUES (${"Alice"})`;
55
+ * console.log(result.lastInsertRowId, result.changes);
56
+ *
57
+ * // With type parameter (no assertion needed)
58
+ * const users = await sql<User>`SELECT * FROM users`; // Type: User[]
59
+ * ```
60
+ */
61
+ then<TResult1 = SQLiteTaggedQueryResult<T>, TResult2 = never>(onfulfilled?: ((value: SQLiteTaggedQueryResult<T>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
62
+ /**
63
+ * Execute the query and return rows as arrays of values (Bun-style).
64
+ * Each row is an array where values are in column order.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * const rows = await sql`SELECT name, age FROM users`.values();
69
+ * // Returns: [["Alice", 30], ["Bob", 25]]
70
+ * ```
71
+ */
72
+ values(): Promise<any[][]>;
73
+ /**
74
+ * Execute the query and return the first row only.
75
+ * Returns null if no rows match.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * const user = await sql`SELECT * FROM users WHERE id = ${1}`.first();
80
+ * ```
81
+ */
82
+ first(): Promise<T | null>;
83
+ /**
84
+ * Execute the query and return an async iterator over the rows.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * for await (const user of sql`SELECT * FROM users`.each()) {
89
+ * console.log(user.name);
90
+ * }
91
+ * ```
92
+ */
93
+ each(): AsyncIterableIterator<T>;
94
+ /**
95
+ * Execute a query synchronously that returns rows or metadata based on query type.
96
+ * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
97
+ */
98
+ allSync(): SQLiteTaggedQueryResult<T>;
99
+ /**
100
+ * Execute the query synchronously and return rows as arrays of values.
101
+ * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
102
+ */
103
+ valuesSync(): any[][];
104
+ /**
105
+ * Execute the query synchronously and return the first row.
106
+ * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
107
+ */
108
+ firstSync(): T | null;
109
+ /**
110
+ * Execute the query synchronously and return an iterator.
111
+ * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
112
+ */
113
+ eachSync(): IterableIterator<T>;
114
+ }
115
+ export {};
116
+ //# sourceMappingURL=SQLiteTaggedQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SQLiteTaggedQuery.d.ts","sourceRoot":"","sources":["../src/SQLiteTaggedQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD;;;GAGG;AACH,KAAK,uBAAuB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,eAAe,GAAG,CAAC,EAAE,CAAC;AAE5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,iBAAiB,CAAC,CAAC,GAAG,OAAO,CAAE,YAAW,WAAW,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;IAM1F,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAL3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAgB;gBAGxB,QAAQ,EAAE,cAAc,EACzC,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,OAAO,EAAE;IAQnB;;;;;;;;;;;;;;;;OAgBG;IACH,IAAI,CAAC,QAAQ,GAAG,uBAAuB,CAAC,CAAC,CAAC,EAAE,QAAQ,GAAG,KAAK,EAC1D,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAC,CAAC,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,EAC9F,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,GACtE,WAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAUnC;;;;;;;;;OASG;IACG,MAAM,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;IAUhC;;;;;;;;OAQG;IACG,KAAK,IAAI,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAIhC;;;;;;;;;OASG;IACH,IAAI,IAAI,qBAAqB,CAAC,CAAC,CAAC;IAMhC;;;OAGG;IACH,OAAO,IAAI,uBAAuB,CAAC,CAAC,CAAC;IAUrC;;;OAGG;IACH,UAAU,IAAI,GAAG,EAAE,EAAE;IAUrB;;;OAGG;IACH,SAAS,IAAI,CAAC,GAAG,IAAI;IAIrB;;;OAGG;IACH,QAAQ,IAAI,gBAAgB,CAAC,CAAC,CAAC;CAGhC"}
@@ -0,0 +1,160 @@
1
+ import { parseSQLQuery } from './queryUtils';
2
+ /**
3
+ * A SQL query with tagged template literals API that can be awaited directly (returns array of objects by default),
4
+ * or transformed using .values() or .first() methods.
5
+ *
6
+ * This API is inspired by Bun's SQL interface:
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * // Default: returns array of objects
11
+ * const users = await sql`SELECT * FROM users WHERE age > ${21}`;
12
+ *
13
+ * // Get values as arrays
14
+ * const values = await sql`SELECT name, age FROM users`.values();
15
+ * // Returns: [["Alice", 30], ["Bob", 25]]
16
+ *
17
+ * // Get first row only
18
+ * const user = await sql`SELECT * FROM users WHERE id = ${1}`.first();
19
+ *
20
+ * // With type parameter
21
+ * const users = await sql<User>`SELECT * FROM users`;
22
+ *
23
+ * // Mutable queries return SQLiteRunResult
24
+ * const result = await sql`INSERT INTO users (name) VALUES (${"Alice"})` as SQLiteRunResult;
25
+ * console.log(result.lastInsertRowId, result.changes);
26
+ *
27
+ * // Synchronous API
28
+ * const users = sql<User>`SELECT * FROM users WHERE age > ${21}`.allSync();
29
+ * const user = sql<User>`SELECT * FROM users WHERE id = ${userId}`.firstSync();
30
+ * ```
31
+ */
32
+ export class SQLiteTaggedQuery {
33
+ database;
34
+ source;
35
+ params;
36
+ parsedInfo;
37
+ constructor(database, strings, values) {
38
+ this.database = database;
39
+ const sql = strings.join('?');
40
+ this.source = sql;
41
+ this.params = values;
42
+ this.parsedInfo = parseSQLQuery(sql);
43
+ }
44
+ /**
45
+ * Make a query awaitable that automatically returns rows or metadata based on query type.
46
+ * This is called automatically when you await the query.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * // SELECT returns array of objects
51
+ * const users = await sql`SELECT * FROM users`;
52
+ *
53
+ * // INSERT returns metadata
54
+ * const result = await sql`INSERT INTO users (name) VALUES (${"Alice"})`;
55
+ * console.log(result.lastInsertRowId, result.changes);
56
+ *
57
+ * // With type parameter (no assertion needed)
58
+ * const users = await sql<User>`SELECT * FROM users`; // Type: User[]
59
+ * ```
60
+ */
61
+ then(onfulfilled, onrejected) {
62
+ if (this.parsedInfo.canReturnRows) {
63
+ // SELECT, PRAGMA, WITH, EXPLAIN, or has RETURNING clause
64
+ return this.database.getAllAsync(this.source, this.params).then(onfulfilled, onrejected);
65
+ }
66
+ else {
67
+ // INSERT, UPDATE, DELETE without RETURNING
68
+ return this.database.runAsync(this.source, this.params).then(onfulfilled, onrejected);
69
+ }
70
+ }
71
+ /**
72
+ * Execute the query and return rows as arrays of values (Bun-style).
73
+ * Each row is an array where values are in column order.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * const rows = await sql`SELECT name, age FROM users`.values();
78
+ * // Returns: [["Alice", 30], ["Bob", 25]]
79
+ * ```
80
+ */
81
+ async values() {
82
+ const statement = await this.database.prepareAsync(this.source);
83
+ try {
84
+ const result = await statement.executeForRawResultAsync(this.params);
85
+ return await result.getAllAsync();
86
+ }
87
+ finally {
88
+ await statement.finalizeAsync();
89
+ }
90
+ }
91
+ /**
92
+ * Execute the query and return the first row only.
93
+ * Returns null if no rows match.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * const user = await sql`SELECT * FROM users WHERE id = ${1}`.first();
98
+ * ```
99
+ */
100
+ async first() {
101
+ return this.database.getFirstAsync(this.source, this.params);
102
+ }
103
+ /**
104
+ * Execute the query and return an async iterator over the rows.
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * for await (const user of sql`SELECT * FROM users`.each()) {
109
+ * console.log(user.name);
110
+ * }
111
+ * ```
112
+ */
113
+ each() {
114
+ return this.database.getEachAsync(this.source, this.params);
115
+ }
116
+ // Synchronous variants
117
+ /**
118
+ * Execute a query synchronously that returns rows or metadata based on query type.
119
+ * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
120
+ */
121
+ allSync() {
122
+ if (this.parsedInfo.canReturnRows) {
123
+ // SELECT, PRAGMA, WITH, EXPLAIN, or has RETURNING clause
124
+ return this.database.getAllSync(this.source, this.params);
125
+ }
126
+ else {
127
+ // INSERT, UPDATE, DELETE without RETURNING
128
+ return this.database.runSync(this.source, this.params);
129
+ }
130
+ }
131
+ /**
132
+ * Execute the query synchronously and return rows as arrays of values.
133
+ * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
134
+ */
135
+ valuesSync() {
136
+ const statement = this.database.prepareSync(this.source);
137
+ try {
138
+ const result = statement.executeForRawResultSync(this.params);
139
+ return result.getAllSync();
140
+ }
141
+ finally {
142
+ statement.finalizeSync();
143
+ }
144
+ }
145
+ /**
146
+ * Execute the query synchronously and return the first row.
147
+ * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
148
+ */
149
+ firstSync() {
150
+ return this.database.getFirstSync(this.source, this.params);
151
+ }
152
+ /**
153
+ * Execute the query synchronously and return an iterator.
154
+ * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.
155
+ */
156
+ eachSync() {
157
+ return this.database.getEachSync(this.source, this.params);
158
+ }
159
+ }
160
+ //# sourceMappingURL=SQLiteTaggedQuery.js.map