Skip to content

SqliteStateProvider

SqliteStateProvider<TTxContext> = object

Defined in: packages/sqlite/src/state-provider/state-provider.sqlite.ts:14

SQLite state provider interface.

Abstracts database client operations, providing context management, transaction handling, and SQL execution. Users create their own implementation to integrate with their preferred SQLite client (better-sqlite3, etc.).

TTxContext extends BaseTxContext

The transaction context type containing database client/connection info

optional close?: () => Promise<void>

Defined in: packages/sqlite/src/state-provider/state-provider.sqlite.ts:76

Releases provider-owned resources. Optional — pass-through providers (user-owned driver) can omit it. When defined, must be idempotent.

Promise<void>


executeSql: (options) => Promise<unknown[]>

Defined in: packages/sqlite/src/state-provider/state-provider.sqlite.ts:62

Executes a SQL query. When txCtx is provided, uses that transaction connection. When txCtx is omitted, acquires a connection, executes, and releases.

id is a stable cache key for prepared statements. It uniquely identifies the resolved SQL within this provider instance (the adapter folds template variants like tablePrefix into the suffix), so providers MAY cache db.prepare(sql) handles by id alone (typical for better-sqlite3 / node:sqlite). When omitted, the provider must execute the statement unprepared — the adapter omits id for one-off or dynamic SQL (e.g. savepoints).

When columnTypes is non-empty the query returns rows (use .all()); when empty the query is a mutation (use .run() / .exec()).

paramTypes annotates each positional parameter’s runtime type. The built-in adapter pre-serializes non-primitive values to strings before they reach the provider, so the standard better-sqlite3 / node:sqlite providers ignore this field. It exists for custom providers backed by drivers that need explicit type hints (e.g. remote SQLite bridges).

readOnly indicates whether the statement reads only (SELECT without FOR UPDATE). Providers use this to pick between shared/exclusive locks or reader/writer connection pools.

Record<string, RuntimeType>

string

unknown[]

Record<number, RuntimeType>

boolean

string

TTxContext

Promise<unknown[]>


transactionConcurrency: "concurrent" | "serialized"

Defined in: packages/sqlite/src/state-provider/state-provider.sqlite.ts:19

Whether two withTransaction callbacks can run concurrently against the underlying database.


optional withSavepoint?: <T>(txCtx, fn) => Promise<T>

Defined in: packages/sqlite/src/state-provider/state-provider.sqlite.ts:36

Executes a callback within a savepoint inside an existing transaction. Creates a savepoint, executes the callback, releases on success, rolls back to the savepoint on error.

Optional. When not provided, the adapter uses raw SAVEPOINT SQL via executeSql. Override when the driver tracks transaction state client-side.

T

TTxContext

(txCtx) => Promise<T>

Promise<T>


withTransaction: <T>(fn) => Promise<T>

Defined in: packages/sqlite/src/state-provider/state-provider.sqlite.ts:26

Executes a callback within a database transaction. Acquires a connection, starts a transaction, executes the callback, commits on success, rolls back on error, and releases the connection.

T

(txCtx) => Promise<T>

Promise<T>