NitroSQLite
react-native-nitro-sqlite-drizzleClasses

NitroSQLiteTransaction

TypeScript

Source files: TypeScript

Drizzle transaction handle supplied to a transaction callback. Use it for queries and nested transactions only while the callback is active. Await each nested call before using its parent handle again. Descendants must nest through the handle supplied to their own callback, not an ancestor handle. Queries and prepared queries through a child reject after its callback ends, even while the parent transaction remains active. Inherited rollback() throws Drizzle's TransactionRollbackError; an error escaping the outer callback becomes a NitroSQLiteError with message Rollback.

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 NitroSQLiteTransaction<TFullSchema, TSchema>(resultType, dialect, transactionSession, schema, nestedIndex?): NitroSQLiteTransaction<TFullSchema, TSchema>

Defined in: packages/integrations/react-native/drizzle/src/session.ts:199

Bind a Drizzle transaction to its own callback scope.

Parameters

resultType

"async"

Drizzle's asynchronous execution mode.

dialect

SQLiteAsyncDialect

SQLite SQL compiler.

transactionSession

NitroSQLiteSession<TFullSchema, TSchema>

Session using the outer managed transaction's connection.

schema

RelationalSchemaConfig<TSchema> | undefined

Relational schema configuration, if supplied.

nestedIndex?

number = 0

Savepoint depth, starting at zero for the outer transaction.

Returns

NitroSQLiteTransaction<TFullSchema, TSchema>

Overrides

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

Properties

dialect

readonly dialect: SQLiteAsyncDialect

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

Inherited from

SQLiteTransaction.dialect


session

readonly session: SQLiteSession<"async", NativeRawQueryResult, TFullSchema, TSchema>

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

Inherited from

SQLiteTransaction.session

Methods

transaction()

transaction<T>(transaction): Promise<T>

Defined in: packages/integrations/react-native/drizzle/src/session.ts:239

Run a nested transaction using a SQLite savepoint. Only one nested call can be active on this handle. Await it before starting a sibling or using the parent handle. To nest further, use the child handle. Overlap rejects immediately without invoking the callback or executing SQL; calls are not queued because an ancestor call could wait on its own descendant.

Type Parameters

T

T

Nested callback result type.

Parameters

transaction

(tx) => Promise<T>

Callback whose changes roll back to the savepoint if it throws.

Returns

Promise<T>

The callback result after releasing the savepoint.

Throws

Rejects on overlap, a finished handle, or a callback that returns with an active child. Callback errors roll back and release the savepoint, then reject with the original error. Catch these errors in the parent to continue. Savepoint failures also force the outer transaction to roll back, even if caught. A cleanup failure preserves both errors in an AggregateError cause.

Overrides

SQLiteTransaction.transaction

On this page