SqliteClient
Connects Effect SQL to SQLite when running on Bun, using bun:sqlite.
This module opens a SQLite database and exposes it as both SqliteClient and the generic Effect SQL client. It serializes access to the database, enables WAL mode unless disabled, and supports database export and extension loading. Streaming queries and updateValues are not supported by this driver.
Constructors
Layers
Creates a layer from a concrete Bun SQLite client configuration, providing both SqliteClient and SqlClient.
Signature
declare function layer(config: SqliteClientConfig): Layer<SqliteClient | SqlClient>;layerConfig
Creates a layer from a Config-wrapped Bun SQLite client configuration, providing both SqliteClient and SqlClient.
Signature
declare function layerConfig(
config:
| {
readonly create?: Config<boolean | undefined>;
readonly disableWAL?: Config<boolean | undefined>;
readonly filename: Config<string>;
readonly readonly?: Config<boolean | undefined>;
readonly readwrite?: 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
SqliteClientConfig interface
Configuration for a Bun SQLite client, including filename, open mode flags, WAL behavior, span attributes, and query/result name transforms.
Signature
interface SqliteClientConfig {
readonly create?: boolean;
readonly disableWAL?: boolean;
readonly filename: string;
readonly readonly?: boolean;
readonly readwrite?: boolean;
readonly spanAttributes?: Record<string, unknown>;
readonly transformQueryNames?: (str: string) => string;
readonly transformResultNames?: (str: string) => string;
}Services
SqliteClient
Service tag for the Bun SQLite client service.
When to use
Use to access or provide a Bun SQLite client through the Effect context.
Signature
declare const SqliteClient: Service<SqliteClient, SqliteClient>;SqliteClient interface
Bun SQLite client service, extending SqlClient with database export 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-bun/SqliteClient": "~@effect/sql-sqlite-bun/SqliteClient";
readonly config: SqliteClientConfig;
readonly export: Effect<Uint8Array<ArrayBufferLike>, SqlError>;
readonly loadExtension: (path: string) => Effect<void, SqlError>;
readonly updateValues: never;
}
Creates a scoped Bun SQLite client for a database file, enabling WAL by default and serializing access. Streaming queries are not implemented.