SqliteClient.ts
SqliteClient.ts overview
Section titled “SqliteClient.ts overview”Connects Effect SQL to SQLite on Node.js using better-sqlite3.
This module opens a SQLite database and exposes it as both SqliteClient and
the generic Effect SQL client. It serializes access through one connection,
caches prepared statements, enables WAL mode unless disabled, and supports
database export, backup, and extension loading. Streaming queries and
updateValues are not supported by this driver.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”constructors
Section titled “constructors”Creates a scoped node SQLite client from the supplied configuration, using a single serialized connection with WAL enabled by default and exposing SQLite-specific export, backup, and loadExtension operations.
Signature
declare const make: ( options: SqliteClientConfig) => Effect.Effect<SqliteClient, never, Scope.Scope | Reactivity.Reactivity>Since v4.0.0
layers
Section titled “layers”Builds a layer from a node SQLite client configuration, providing both SqliteClient and the generic SqlClient service.
Signature
declare const layer: (config: SqliteClientConfig) => Layer.Layer<SqliteClient | Client.SqlClient>Since v4.0.0
layerConfig
Section titled “layerConfig”Builds a layer from an Effect Config value, providing both the node SqliteClient service and the generic SqlClient service.
Signature
declare const layerConfig: ( config: Config.Wrap<SqliteClientConfig>) => Layer.Layer<SqliteClient | Client.SqlClient, Config.ConfigError>Since v4.0.0
models
Section titled “models”BackupMetadata (interface)
Section titled “BackupMetadata (interface)”Metadata returned from a Node SQLite backup operation, reporting total and remaining page counts.
Signature
export interface BackupMetadata { readonly totalPages: number readonly remainingPages: number}Since v4.0.0
SqliteClient (interface)
Section titled “SqliteClient (interface)”Node SQLite client service, extending SqlClient with database export, backup, and extension loading helpers. updateValues is not supported.
Signature
export interface SqliteClient extends Client.SqlClient { readonly [TypeId]: TypeId readonly config: SqliteClientConfig readonly export: Effect.Effect<Uint8Array, SqlError> readonly backup: (destination: string) => Effect.Effect<BackupMetadata, SqlError> readonly loadExtension: (path: string) => Effect.Effect<void, SqlError>
/** Not supported in sqlite */ readonly updateValues: never}Since v4.0.0
SqliteClientConfig (interface)
Section titled “SqliteClientConfig (interface)”Configuration for a node SQLite client backed by better-sqlite3, including the database filename, read-only mode, statement cache settings, WAL behavior, span attributes, and query/result name transforms.
Signature
export interface SqliteClientConfig { readonly filename: string readonly readonly?: boolean | undefined readonly prepareCacheSize?: number | undefined readonly prepareCacheTTL?: Duration.Input | undefined readonly disableWAL?: boolean | undefined readonly spanAttributes?: Record<string, unknown> | undefined
readonly transformResultNames?: ((str: string) => string) | undefined readonly transformQueryNames?: ((str: string) => string) | undefined}Since v4.0.0
services
Section titled “services”SqliteClient
Section titled “SqliteClient”Service tag for the node SQLite client implementation.
Signature
declare const SqliteClient: Context.Service<SqliteClient, SqliteClient>Since v4.0.0
type IDs
Section titled “type IDs”TypeId
Section titled “TypeId”Runtime type identifier used to mark Node SqliteClient values.
Signature
declare const TypeId: "~@effect/sql-sqlite-node/SqliteClient"Since v4.0.0
TypeId (type alias)
Section titled “TypeId (type alias)”Type-level identifier used to mark Node SqliteClient values.
Signature
type TypeId = "~@effect/sql-sqlite-node/SqliteClient"Since v4.0.0