Skip to content

NodeSqliteStorage

SqlStorage over a SQLite file on Node, through @effect/sql-sqlite-node (built on node:sqlite, no native module). The connection uses pi-durable’s settings: WAL journal, synchronous = NORMAL, a WAL auto-checkpoint threshold, a busy timeout, and a truncating WAL checkpoint on close.

import { NodeSqliteStorage } from "@effective-harness/core"
const StorageLive = NodeSqliteStorage.layer({ filename: "./data/session.sqlite" })

Since v0.0.0


Connection settings of a durable SQLite file.

Signature

export interface Options {
/** The database file, created with its directory when missing; `":memory:"` for a private in-memory database. */
readonly filename: string
/** How long SQLite waits for a competing file lock. Default: 5 seconds. Waiting blocks the event loop. */
readonly busyTimeout?: Duration.Input
/** WAL auto-checkpoint threshold in pages; 0 disables it. Default: 1,000 (SQLite's default). */
readonly walAutoCheckpointPages?: number
/** The schema history to apply on open. Default: `SqlStorage.migrations`. */
readonly migrations?: ReadonlyArray<SqlStorage.SqlMigration>
}

Source

Since v0.0.0

Storage over a SQLite file (or ":memory:"), migrated on open. The database closes with the layer; a new layer over the same file resumes where the last one stopped.

Signature

declare const layer: (options: Options) => Layer.Layer<Storage, StorageFailure>

Source

Since v0.0.0

The configured SqlClient (and SqliteClient) over options.filename, without the storage. Closing the layer checkpoints and truncates the WAL, then closes the database.

Signature

declare const layerSqlClient: (
options: Options
) => Layer.Layer<SqliteClient.SqliteClient | SqlClient.SqlClient, StorageFailure>

Source

Since v0.0.0