NitroSQLite
nitro-sqlite-drizzleClasses

NitroSQLiteSession

TypeScript

Source 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

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?, assertActive?): NitroSQLiteSession<TFullSchema, TSchema>

Defined in: packages/integrations/nitro-ui/drizzle/src/session.ts:65

Bind a session to an existing connection or active transaction.

Parameters

connection

Connection

Open connection used to start managed transactions.

client

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

assertActive?

() => void

Internal callback-scope check, run before executing queries.

Returns

NitroSQLiteSession<TFullSchema, TSchema>

Overrides

SQLiteSession< 'async', NitroSQLiteRawQueryResult, TFullSchema, TSchema >.constructor

Properties

dialect

readonly dialect: SQLiteAsyncDialect

Defined in: packages/integrations/react-native/drizzle/src/drizzle-orm.ts:34

Inherited from

SQLiteSession.dialect

Methods

prepareQuery()

prepareQuery<T>(query, fields, executeMethod, isResponseInArrayMode, customResultMapper?): NitroSQLitePreparedQuery<T>

Defined in: packages/integrations/nitro-ui/drizzle/src/session.ts:88

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

NitroSQLitePreparedQuery<T>

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/integrations/nitro-ui/drizzle/src/session.ts:135

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. Await each nested transaction before starting another on the same handle or returning from the callback. Overlapping nested calls reject before running SQL.

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

On this page