SqliteClient
Connects Effect SQL to SQLite compiled to WebAssembly with @effect/wa-sqlite.
This module can create an in-memory SQLite database in the current runtime or connect to a worker-backed database, such as the OPFS worker from OpfsWorker. Both clients are exposed as SqliteClient and the generic Effect SQL client, serialize access, support database import and export, and can install reactivity hooks from SQLite update notifications. In-memory clients can stream query rows; worker-backed clients cannot. updateValues is not supported by this driver.
Constructors
Signature
declare function make(
options: SqliteClientConfig,
): Effect<SqliteClient, SqlError, Scope | Reactivity>;makeMemory
Creates a scoped in-memory SQLite WASM client using the memory VFS, serializing access through a semaphore and exposing database export and import operations.
Signature
declare function makeMemory(
options: SqliteClientMemoryConfig,
): Effect<SqliteClient, SqlError, Scope | Reactivity>;Layers
Builds a layer from a worker-backed SQLite WASM client configuration, providing both SqliteClient and the generic SqlClient service.
Signature
declare function layer(config: SqliteClientConfig): Layer<SqliteClient | SqlClient, SqlError>;layerConfig
Builds a layer from an Effect Config value, providing both the worker-backed SQLite WASM SqliteClient service and the generic SqlClient service.
Signature
declare function layerConfig(
config:
| {
readonly installReactivityHooks?: Config<boolean | undefined>;
readonly spanAttributes?:
| {
[key: string]: Config<unknown>;
}
| Config<Record<string, unknown> | undefined>;
readonly transformQueryNames?: Config<(str: string) => string | undefined>;
readonly transformResultNames?: Config<(str: string) => string | undefined>;
readonly worker: Config<Effect<MessagePort | Worker | SharedWorker, never, Scope>>;
}
| Config<SqliteClientConfig>,
): Layer<SqliteClient | SqlClient, SqlError | ConfigError>;layerMemory
Builds a layer from an in-memory SQLite WASM client configuration, providing both SqliteClient and the generic SqlClient service.
Signature
declare function layerMemory(
config: SqliteClientMemoryConfig,
): Layer<SqliteClient | SqlClient, SqlError>;layerMemoryConfig
Builds a layer from an Effect Config value, providing both the in-memory SQLite WASM SqliteClient service and the generic SqlClient service.
Signature
declare function layerMemoryConfig(
config:
| {
readonly installReactivityHooks?: Config<boolean | undefined>;
readonly spanAttributes?:
| {
[key: string]: Config<unknown>;
}
| Config<Record<string, unknown> | undefined>;
readonly transformQueryNames?: Config<(str: string) => string | undefined>;
readonly transformResultNames?: Config<(str: string) => string | undefined>;
}
| Config<SqliteClientMemoryConfig>,
): Layer<SqliteClient | SqlClient, SqlError | ConfigError>;Models
SqliteClientConfig interface
Configuration for a worker-backed SQLite WASM client, including the scoped worker or message port, optional reactivity hooks, span attributes, and query/result name transforms.
Signature
interface SqliteClientConfig {
readonly installReactivityHooks?: boolean;
readonly spanAttributes?: Record<string, unknown>;
readonly transformQueryNames?: (str: string) => string;
readonly transformResultNames?: (str: string) => string;
readonly worker: Effect<MessagePort | Worker | SharedWorker, never, Scope>;
}SqliteClientMemoryConfig interface
Configuration for an in-memory SQLite WASM client, including optional reactivity hooks, span attributes, and query/result name transforms.
Signature
interface SqliteClientMemoryConfig {
readonly installReactivityHooks?: boolean;
readonly spanAttributes?: Record<string, unknown>;
readonly transformQueryNames?: (str: string) => string;
readonly transformResultNames?: (str: string) => string;
}Services
SqliteClient
Service tag for the SQLite WASM client.
Signature
declare const SqliteClient: Service<SqliteClient, SqliteClient>;SqliteClient interface
SQLite WASM client service interface, extending SqlClient with database export and import operations and marking updateValues as unsupported for SQLite.
Signature
interface SqliteClient extends SqlClient {
<A extends object = Row>(strings: TemplateStringsArray, ...args: Array<any>): Statement<A>;
(value: string): Identifier;
readonly "~@effect/sql-sqlite-wasm/SqliteClient": "~@effect/sql-sqlite-wasm/SqliteClient";
readonly config: SqliteClientMemoryConfig;
readonly export: Effect<Uint8Array<ArrayBufferLike>, SqlError>;
readonly import: (data: Uint8Array) => Effect<void, SqlError>;
readonly updateValues: never;
}Transferables
Fiber reference that stores transferables to include with worker-backed SQLite WASM query messages.
Signature
declare const Transferables: Reference<readonly Array<Transferable>>Transferables
withTransferables
Runs an effect with the supplied transferables attached to worker-backed SQLite WASM query messages.
Signature
declare function withTransferables(transferables: readonly Array<Transferable>): <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, R>
Creates a scoped worker-backed SQLite WASM client, communicating with the configured worker or message port, restarting the scoped connection on worker errors, and exposing database
exportandimportoperations.