Skip to main content

@flow-state-dev/store-sqlite

Type Aliases​

SQLiteStoreOptions​

type SQLiteStoreOptions = object;

@flow-state-dev/store-sqlite: what an app author imports. sqliteStores is the adapter createFlowState({ stores }) takes, and createSQLiteScheduleIndex (or sqliteScheduleIndex, on a file of its own) backs scheduled flows' dynamic schedules.

The registry factory, the per-store constructors and the schema helpers are for host and adapter authors, on @flow-state-dev/store-sqlite/host.

Properties​

filename​
filename: string;

File path to the SQLite database, or ":memory:" for in-memory

requestStore?​
requestStore?: CreateSQLiteRequestStoreOptions;

Request store live-tail subscription options.

skipSchemaInit?​
skipSchemaInit?: boolean;

Skip schema DDL (CREATE TABLE/INDEX + project→org rename migrations) on construction. Default false. Set to true when migrations are run out-of-band (e.g. as a deploy step). Per-connection PRAGMAs (busy_timeout, synchronous, foreign_keys, etc.) are always applied — they are required for safe concurrent access on every fresh better-sqlite3 connection.

traceStore?​
traceStore?: SQLiteTraceStoreOptions;

Trace store retention options. Defaults to maxRequests: 50.

Functions​

createSQLiteScheduleIndex()​

function createSQLiteScheduleIndex(db): ScheduleIndex;

Build a ScheduleIndex backed by the schedule_index table in the given better-sqlite3 database. Caller owns the Database lifecycle.

Parameters​

db​

Database

Returns​

ScheduleIndex


sqliteScheduleIndex()​

function sqliteScheduleIndex(options): ScheduleIndex;

A ScheduleIndex in a SQLite file of its own at filename, its schema made on open: what a host gives each flow it ticks, since one index ticks one flow, the way sqliteStores({ filename }) gives it its stores. The connection stays open for the life of the process.

Parameters​

options​
filename​

string

Returns​

ScheduleIndex


sqliteStores()​

function sqliteStores(options): StoreAdapter;

SQLite store adapter for createFlowState. Backs the primary capability slot. Wraps createSQLiteStores (synchronous), memoizing the registry so the connection opens once, and disposes it via close().

Parameters​

options​

SQLiteStoreOptions

Returns​

StoreAdapter