|
| 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