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.).
Type Parameters
Section titled “Type Parameters”TTxContext
Section titled “TTxContext”TTxContext extends BaseTxContext
The transaction context type containing database client/connection info
Properties
Section titled “Properties”close?
Section titled “close?”
optionalclose?: () =>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.
Returns
Section titled “Returns”Promise<void>
executeSql
Section titled “executeSql”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.
Parameters
Section titled “Parameters”options
Section titled “options”columnTypes
Section titled “columnTypes”Record<string, RuntimeType>
string
params
Section titled “params”unknown[]
paramTypes
Section titled “paramTypes”Record<number, RuntimeType>
readOnly
Section titled “readOnly”boolean
string
txCtx?
Section titled “txCtx?”TTxContext
Returns
Section titled “Returns”Promise<unknown[]>
transactionConcurrency
Section titled “transactionConcurrency”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.
withSavepoint?
Section titled “withSavepoint?”
optionalwithSavepoint?: <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.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”TTxContext
(txCtx) => Promise<T>
Returns
Section titled “Returns”Promise<T>
withTransaction
Section titled “withTransaction”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.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”(txCtx) => Promise<T>
Returns
Section titled “Returns”Promise<T>