SqliteEventStore
Durable storage on SQLite, through any effect/sql SQLite driver.
The schema relies on SQLite’s single writer for positions to follow commit order, so it is not portable to other databases.
An append is one statement, which checks the stream’s version and inserts the events only if it still matches. Appends that arrive while others are being written go together into one transaction, so they share the cost of a commit.
Interfaces
Section titled “Interfaces”Options
Section titled “Options”Defined in: src/SqliteEventStore.ts:18
Properties
Section titled “Properties”checkpointsTable?
Section titled “checkpointsTable?”
readonlyoptionalcheckpointsTable?:string
Defined in: src/SqliteEventStore.ts:20
eventsTable?
Section titled “eventsTable?”
readonlyoptionaleventsTable?:string
Defined in: src/SqliteEventStore.ts:19
migrate?
Section titled “migrate?”
readonlyoptionalmigrate?:boolean
Defined in: src/SqliteEventStore.ts:26
Creates the tables, or brings tables of an earlier version up to date, on
startup. Defaults to true. Set it to false where the application may not
change the schema, and apply migrations with your own tooling.
pollInterval?
Section titled “pollInterval?”
readonlyoptionalpollInterval?:Input
Defined in: src/SqliteEventStore.ts:31
Reads the head this often, so subscribers notice appends that other processes
make to the same file. Off by default. See EventStore.MakeOptions.
Type Aliases
Section titled “Type Aliases”Migration
Section titled “Migration”Migration =
Migration
Defined in: src/SqliteEventStore.ts:35
A schema change, see EventStore.Migration. Migrations are listed in the order to apply them.
Variables
Section titled “Variables”
constmake: (…args) =>Effect<{afterCommit?: <R>(effect) =>Effect<void,never,R>;changes:Stream<number>;head:Effect<number,EventStoreError>;append(input):Effect<readonlyobject[],EventStoreError|ConcurrencyConflict>;read(filter?):Stream<{aggregateId:string;aggregateName:string;causationId:string|null;correlationId:string|null;metadata: {[key:string]:Json; };payload:Json;position:number;schemaVersion:number;timestamp:Utc;type:string;version:number; },EventStoreError>;subscribe(filter?):Stream<{aggregateId:string;aggregateName:string;causationId:string|null;correlationId:string|null;metadata: {[key:string]:Json; };payload:Json;position:number;schemaVersion:number;timestamp:Utc;type:string;version:number; },EventStoreError>; },EventStoreError,Scope|SqlClient>
Defined in: src/SqliteEventStore.ts:173
Parameters
Section titled “Parameters”…[options?: Options]
Returns
Section titled “Returns”Effect<{ afterCommit?: <R>(effect) => Effect<void, never, R>; changes: Stream<number>; head: Effect<number, EventStoreError>; append(input): Effect<readonly object[], EventStoreError | ConcurrencyConflict>; read(filter?): Stream<{ aggregateId: string; aggregateName: string; causationId: string | null; correlationId: string | null; metadata: {[key: string]: Json; }; payload: Json; position: number; schemaVersion: number; timestamp: Utc; type: string; version: number; }, EventStoreError>; subscribe(filter?): Stream<{ aggregateId: string; aggregateName: string; causationId: string | null; correlationId: string | null; metadata: {[key: string]: Json; }; payload: Json; position: number; schemaVersion: number; timestamp: Utc; type: string; version: number; }, EventStoreError>; }, EventStoreError, Scope | SqlClient>
Functions
Section titled “Functions”layer()
Section titled “layer()”layer(
options?):Layer<EventStore,EventStoreError,SqlClient>
Defined in: src/SqliteEventStore.ts:310
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”Layer<EventStore, EventStoreError, SqlClient>
layerCheckpoints()
Section titled “layerCheckpoints()”layerCheckpoints(
options?):Layer<Checkpoints,EventStoreError,SqlClient>
Defined in: src/SqliteEventStore.ts:316
Keeps checkpoints in the same database, for view models that are durable too.
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”Layer<Checkpoints, EventStoreError, SqlClient>
migrations()
Section titled “migrations()”migrations(
options?): readonlyMigration[]
Defined in: src/SqliteEventStore.ts:123
The schema of the events and checkpoints tables, for tools that apply migrations
themselves. layer and layerCheckpoints run the same statements on startup
unless migrate is false. SQLite can’t add a column only if it is missing, so
the ALTER TABLE statements must run exactly once.
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”readonly Migration[]