NitroSQLiteSession
TypeScriptSource files: TypeScript
Executes Drizzle queries through a Nitro SQLite connection or transaction. drizzle creates sessions for normal use. A session does not close its connection; a transaction-bound session is usable only within its callback.
Extends
SQLiteSession<"async",NitroSQLiteRawQueryResult,TFullSchema,TSchema>
Type Parameters
TFullSchema
TFullSchema extends Record<string, unknown>
Full schema object supplied to Drizzle.
TSchema
TSchema extends TablesRelationalConfig
Relational table configuration extracted from that schema.
Constructors
Constructor
new NitroSQLiteSession<TFullSchema, TSchema>(connection, client, dialect, schema, options?): NitroSQLiteSession<TFullSchema, TSchema>
Defined in: packages/react-native-nitro-sqlite-drizzle/src/session.ts:64
Bind a session to an existing connection or active transaction.
Parameters
connection
Open connection used to start managed transactions.
client
NitroSQLiteConnection | Transaction
The connection, or the active transaction used for queries.
dialect
SQLiteAsyncDialect
Asynchronous SQLite dialect used to compile queries.
schema
RelationalSchemaConfig<TSchema> | undefined
Relational schema configuration, or undefined when none was supplied.
options?
NitroSQLiteSessionOptions = {}
Query logging options, inherited by transactions.
Returns
NitroSQLiteSession<TFullSchema, TSchema>
Overrides
SQLiteSession< 'async', NitroSQLiteRawQueryResult, TFullSchema, TSchema >.constructor
Properties
dialect
readonly dialect: SQLiteAsyncDialect
Defined in: packages/react-native-nitro-sqlite-drizzle/src/drizzle-orm.ts:34
Inherited from
SQLiteSession.dialect
Methods
prepareQuery()
prepareQuery<T>(query, fields, executeMethod, isResponseInArrayMode, customResultMapper?): NitroSQLitePreparedQuery<T>
Defined in: packages/react-native-nitro-sqlite-drizzle/src/session.ts:86
Create a reusable query wrapper without preparing a native SQLite statement.
Type Parameters
T
T extends PreparedQueryConfig & object
Result types for the query's execution methods.
Parameters
query
Query
Compiled SQL and positional parameters, including placeholders.
fields
SelectedFieldsOrdered | undefined
Ordered selected fields used to decode result rows.
executeMethod
SQLiteExecuteMethod
Method invoked by the wrapper's execute() call.
isResponseInArrayMode
boolean
Whether Drizzle expects positional rows.
customResultMapper?
(rows) => unknown
Optional decoder for relational query results.
Returns
A wrapper bound to this session's client. It needs no disposal.
Overrides
SQLiteSession.prepareQuery
transaction()
transaction<T>(transaction, _config?): Promise<T>
Defined in: packages/react-native-nitro-sqlite-drizzle/src/session.ts:116
Hold the connection until an asynchronous transaction callback finishes.
Await every query through tx; awaiting queries through the outer database
waits for this transaction and deadlocks the callback.
Type Parameters
T
T
Callback result type.
Parameters
transaction
(tx) => Promise<T>
Callback that commits on success and rolls back on failure.
_config?
SQLiteTransactionConfig
Accepted for Drizzle compatibility. behavior is ignored;
the connection starts the transaction with BEGIN.
Returns
Promise<T>
The callback result after the transaction commits.
Throws
Rejects with NitroSQLiteError on query, callback, or finalization failure.
An uncaught tx.rollback() rejects with the message Rollback.
Overrides
SQLiteSession.transaction