SqliteClient
Connects Effect SQL to SQLite on Node.js using node:sqlite.
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 backup, and extension loading. Streaming queries and updateValues are not supported by this driver.
Constructors
Layers
Builds a layer from a node SQLite client configuration, providing both SqliteClient and the generic SqlClient service.
Signature
declare function layer(config: SqliteClientConfig): Layer<SqliteClient | SqlClient>;layerConfig
Builds a layer from an Effect Config value, providing both the node SqliteClient service and the generic SqlClient service.
Signature
declare function layerConfig(
config:
| {
readonly disableWAL?: Config<boolean | undefined>;
readonly filename: Config<string>;
readonly prepareCacheSize?: Config<number | undefined>;
readonly prepareCacheTTL?: Config<Input | undefined>;
readonly readonly?: 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<SqliteClientConfig>,
): Layer<SqliteClient | SqlClient, ConfigError>;Models
BackupMetadata interface
Metadata returned from a Node SQLite backup operation, reporting total and remaining page counts.
Signature
interface BackupMetadata {
readonly remainingPages: number;
readonly totalPages: number;
}SqliteClientConfig interface
Configuration for a node SQLite client backed by node:sqlite, including the database filename, read-only mode, statement cache settings, WAL behavior, span attributes, and query/result name transforms.
Signature
interface SqliteClientConfig {
readonly disableWAL?: boolean;
readonly filename: string;
readonly prepareCacheSize?: number;
readonly prepareCacheTTL?: Input;
readonly readonly?: boolean;
readonly spanAttributes?: Record<string, unknown>;
readonly transformQueryNames?: (str: string) => string;
readonly transformResultNames?: (str: string) => string;
}Services
SqliteClient
Service tag for the node SQLite client implementation.
Signature
declare const SqliteClient: Service<SqliteClient, SqliteClient>;SqliteClient interface
Node SQLite client service, extending SqlClient with database export, backup, and extension loading helpers. updateValues is not supported.
Signature
interface SqliteClient extends SqlClient {
<A extends object = Row>(strings: TemplateStringsArray, ...args: Array<any>): Statement<A>;
(value: string): Identifier;
readonly "~@effect/sql-sqlite-node/SqliteClient": "~@effect/sql-sqlite-node/SqliteClient";
readonly backup: (destination: string) => Effect<BackupMetadata, SqlError>;
readonly config: SqliteClientConfig;
readonly loadExtension: (path: string) => Effect<void, SqlError>;
readonly updateValues: never;
}
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, andloadExtensionoperations.