Skip to content

Commit 7e424c0

Browse files
chrispadercodex
andcommitted
refactor: shorten SQLite type and helper names
Co-authored-by: Codex <noreply@openai.com>
1 parent 66c38e0 commit 7e424c0

108 files changed

Lines changed: 978 additions & 701 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/ci-paths.json‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@
5151
".github/actions/**",
5252
".github/ci-paths.json",
5353
"scripts/ci*",
54-
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteDatabaseMigration.*",
55-
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteDatabaseConnections.*",
56-
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteExecuteBatch.*",
57-
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteOperations.*",
58-
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteStatementGroup.hpp",
59-
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteStatementTail.hpp",
54+
"packages/react-native-nitro-sqlite/cpp/SQLiteDatabaseMigration.*",
55+
"packages/react-native-nitro-sqlite/cpp/SQLiteDatabaseConnections.*",
56+
"packages/react-native-nitro-sqlite/cpp/SQLiteExecuteBatch.*",
57+
"packages/react-native-nitro-sqlite/cpp/SQLiteOperations.*",
58+
"packages/react-native-nitro-sqlite/cpp/SQLiteStatementGroup.hpp",
59+
"packages/react-native-nitro-sqlite/cpp/SQLiteStatementTail.hpp",
6060
"packages/react-native-nitro-sqlite/cpp/sqlite/sqlite3.*",
6161
"packages/react-native-nitro-sqlite/cpp/sqlite/sqlite3-symbol-prefix.h",
6262
"packages/react-native-nitro-sqlite-vec/cpp/**",

‎docs/content/docs/guides/attach-databases.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ db.close()
2828

2929
## File paths and aliases
3030

31-
The example assumes the tables and files already exist. SQLite can create the attached file when it is missing, so verify the intended path when opening prepopulated data. `attach()` and `detach()` are synchronous connection operations; they fail while the connection queue is busy. A failed attach or detach throws `NitroSQLiteError` through the connection wrapper.
31+
The example assumes the tables and files already exist. SQLite can create the attached file when it is missing, so verify the intended path when opening prepopulated data. `attach()` and `detach()` are synchronous connection operations; they fail while the connection queue is busy. A failed attach or detach throws `SQLiteError` through the connection wrapper.
3232

33-
Only pass database names, locations, and aliases you control. The library does not bind these as parameters. Query values still belong in `?` parameters. See [database lifecycle](/docs/guides/database-lifecycle) for the location convention and the generated [`NitroSQLiteConnection` reference](/api/react-native-nitro-sqlite/interfaces/NitroSQLiteConnection) for signatures.
33+
Only pass database names, locations, and aliases you control. The library does not bind these as parameters. Query values still belong in `?` parameters. See [database lifecycle](/docs/guides/database-lifecycle) for the location convention and the generated [`Connection` reference](/api/react-native-nitro-sqlite/interfaces/Connection) for signatures.

‎docs/content/docs/guides/database-lifecycle.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Only pass database names and locations you control. The library does not validat
4747

4848
To open a prepopulated database, copy the SQLite file into the intended app directory before calling `open()`. Use the same `name` and `location` when you open it. A missing file creates a new, empty database, so verify the copy if your schema must already exist. See [file lifetimes](/docs/concepts/databases-and-connections#file-lifetimes) for WAL companion files.
4949

50-
The platform pages describe the database roots and storage settings for [iOS](/docs/configuration/ios#database-location), [Android](/docs/configuration/android#database-location), and [macOS](/docs/configuration/macos). The generated [`NitroSQLiteConnection` reference](/api/react-native-nitro-sqlite/interfaces/NitroSQLiteConnection) lists the lifecycle methods.
50+
The platform pages describe the database roots and storage settings for [iOS](/docs/configuration/ios#database-location), [Android](/docs/configuration/android#database-location), and [macOS](/docs/configuration/macos). The generated [`Connection` reference](/api/react-native-nitro-sqlite/interfaces/Connection) lists the lifecycle methods.
5151

5252
## Runtime teardown
5353

‎docs/content/docs/guides/encryption.mdx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ export function openPrivateDatabase(encryptionKey: string) {
6161

6262
Use a new database name when adding encryption to an app. Passing a key to an existing plaintext database fails; it does not encrypt that file. To migrate, open the old file without a key, create a separate keyed database, copy the data, and verify the new file before removing the old one. See [database lifecycle](/docs/guides/database-lifecycle) for file and connection cleanup.
6363

64-
The [`open()` reference](/api/react-native-nitro-sqlite/functions/open) documents the managed call, and [`NitroSQLiteConnectionOptions`](/api/react-native-nitro-sqlite/interfaces/NitroSQLiteConnectionOptions) lists its options. Raw native callers can pass the key as the fourth argument to [`NitroSQLiteNative.open()`](/api/react-native-nitro-sqlite/hybrid-objects/NitroSQLiteNative) or `openConnection()`, after `readOnly`. The [TypeORM integration](/docs/integrations/typeorm#encrypt-a-typeorm-database) passes the key through `extra`.
64+
The [`open()` reference](/api/react-native-nitro-sqlite/functions/open) documents the managed call, and [`ConnectionOptions`](/api/react-native-nitro-sqlite/interfaces/ConnectionOptions) lists its options. Raw native callers can pass the key as the fourth argument to [`NativeSQLite.open()`](/api/react-native-nitro-sqlite/hybrid-objects/NativeSQLite) or `openConnection()`, after `readOnly`. The [TypeORM integration](/docs/integrations/typeorm#encrypt-a-typeorm-database) passes the key through `extra`.
6565

6666
## Handle open failures
6767

68-
Managed `open()` throws `NitroSQLiteError`. Check its `type` when you need to tell a missing SEE build from a bad key:
68+
Managed `open()` throws `SQLiteError`. Check its `type` when you need to tell a missing SEE build from a bad key:
6969

7070
| `error.type` | Cause | What to do |
7171
| --------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
7272
| `EncryptionNotEnabled` | You supplied a key, but the native build does not include SEE. | Check the source replacement and compile flag, then rebuild the app. |
7373
| `DatabaseCannotBeDecrypted` | The key is empty or contains a NUL byte, the file is plaintext, or SEE cannot read it with that key. | Check the key and file. Migrate a plaintext database before opening it with a key. |
7474

75-
A keyed open checks the database header and reads its schema before returning, so these failures surface during `open()`. Omitting the key keeps the usual unencrypted open path; an encrypted file then fails when SQLite first tries to read it. Calls through `NitroSQLite.native` throw raw native errors rather than `NitroSQLiteError`.
75+
A keyed open checks the database header and reads its schema before returning, so these failures surface during `open()`. Omitting the key keeps the usual unencrypted open path; an encrypted file then fails when SQLite first tries to read it. Calls through `NitroSQLite.native` throw raw native errors rather than `SQLiteError`.
7676

7777
SEE does not encrypt TEMP tables or in-memory databases. Keep sensitive data in the keyed database file rather than those locations. A keyed open adds a header read and schema query; query and write costs depend on the SEE algorithm you choose. Measure those costs on your target devices. See [SQLite's SEE documentation](https://www.sqlite.org/see/doc/trunk/www/readme.wiki) for its encryption variants and limits.

‎docs/content/docs/guides/load-sql-file.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ The loader counts executed lines in `commands` and adds their affected row count
3030

3131
SQLite can reject a statement or fail to commit the import. NitroSQLite attempts one rollback after a failed import transaction, preserving the source path and the original SQL error. Statement failures also include the one-based file line and failing command. A failed BEGIN does not trigger rollback of an existing transaction. If rollback itself fails, its error is appended to the original import error.
3232

33-
The managed methods throw or reject with `NitroSQLiteError` and native category `CouldNotLoadFile`. After a successful rollback, completed statements from the file are discarded and the connection can be used again. The error includes the failing SQL text, so avoid including sensitive literal values in files whose errors may be logged.
33+
The managed methods throw or reject with `SQLiteError` and native category `CouldNotLoadFile`. After a successful rollback, completed statements from the file are discarded and the connection can be used again. The error includes the failing SQL text, so avoid including sensitive literal values in files whose errors may be logged.
3434

3535
Both methods return a [`FileLoadResult`](/api/react-native-nitro-sqlite/interfaces/FileLoadResult) with optional `commands` and `rowsAffected` numbers.

‎docs/content/docs/guides/meta.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"attach-databases",
1414
"load-sql-file",
1515
"performance",
16+
"migrate-to-nitro-v1",
1617
"migrate-from-quick-sqlite",
1718
"ai-agents"
1819
]
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: Migrate to Nitro V1
3+
description: Update type imports for the Nitro V1 migration.
4+
---
5+
6+
A SQLite connection owns a database handle. A prepared statement belongs to that connection, and a query result contains the rows and metadata returned by a statement. Nitro SQLite uses shorter names for these types with Nitro V1.
7+
8+
Update your type imports using the table below. The old names remain available as deprecated aliases.
9+
10+
| Previous name | Replacement |
11+
| -------------------------------- | ------------------------- |
12+
| `NitroSQLiteConnection` | `Connection` |
13+
| `NitroSQLiteConnectionOptions` | `ConnectionOptions` |
14+
| `NitroSQLiteQueryResultRows` | `QueryResultRows` |
15+
| `NitroSQLiteQueryColumnMetadata` | `QueryColumnMetadata` |
16+
| `NitroSQLiteQueryResult` | `NativeQueryResult` |
17+
| `NitroSQLiteQueryRows` | `NativeQueryRows` |
18+
| `NitroSQLitePreparedStatement` | `NativePreparedStatement` |
19+
| `NitroSQLiteNative` | `NativeSQLite` |
20+
| `NitroSQLiteError` | `SQLiteError` |
21+
| `NitroSQLiteExceptionType` | `SQLiteExceptionType` |
22+
| `TypeOrmNitroSQLiteConnection` | `TypeOrmConnection` |
23+
24+
`NativeQueryResult`, `NativePreparedStatement`, and `NativeSQLite` describe values exposed through `NitroSQLite.native`. The managed API keeps its `QueryResult` and `PreparedStatement` names.
25+
26+
```ts
27+
import { open, SQLiteError } from 'react-native-nitro-sqlite'
28+
import type { ConnectionOptions } from 'react-native-nitro-sqlite'
29+
30+
const options: ConnectionOptions = { name: 'app.sqlite' }
31+
const db = open(options)
32+
33+
try {
34+
const { results } = db.execute('SELECT sqlite_version() AS version')
35+
console.log(results[0]?.version)
36+
} catch (error) {
37+
if (error instanceof SQLiteError) {
38+
console.error(error.type, error.message)
39+
} else {
40+
throw error
41+
}
42+
} finally {
43+
db.close()
44+
}
45+
```
46+
47+
`SQLiteError` and `NitroSQLiteError` refer to the same constructor, and both exception-category exports refer to the same object. The error's `name` remains `NitroSQLiteError`.
48+
49+
If your native code includes helper headers, replace their `NitroSQLite` filename prefix with `SQLite`, for example `NitroSQLiteOperations.hpp` becomes `SQLiteOperations.hpp`. The package name, `NitroSQLite` entry point, and native module names stay the same.
50+
51+
See [Getting Started](/docs) for Nitro V1's platform requirements and Swift Package Manager setup.

0 commit comments

Comments
 (0)