SqliteClient.ts
SqliteClient.ts overview
Section titled “SqliteClient.ts overview”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.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”constructors
Section titled “constructors”Creates a scoped Bun SQLite client for a database file, enabling WAL by default and serializing access. Streaming queries are not implemented.
Signature
declare const make: ( options: SqliteClientConfig) => Effect.Effect<SqliteClient, never, Scope.Scope | Reactivity.Reactivity>Since v4.0.0
layers
Section titled “layers”Creates a layer from a concrete Bun SQLite client configuration, providing both SqliteClient and SqlClient.
Signature
declare const layer: (config: SqliteClientConfig) => Layer.Layer<SqliteClient | Client.SqlClient>Since v4.0.0
layerConfig
Section titled “layerConfig”Creates a layer from a Config-wrapped Bun SQLite client configuration, providing both SqliteClient and SqlClient.
Signature
declare const layerConfig: ( config: Config.Wrap<SqliteClientConfig>) => Layer.Layer<SqliteClient | Client.SqlClient, Config.ConfigError>Since v4.0.0
models
Section titled “models”SqliteClient (interface)
Section titled “SqliteClient (interface)”Bun SQLite client service, extending SqlClient with database export 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 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 Bun SQLite client, including filename, open mode flags, WAL behavior, span attributes, and query/result name transforms.
Signature
export interface SqliteClientConfig { readonly filename: string readonly readonly?: boolean | undefined readonly create?: boolean | undefined readonly readwrite?: boolean | 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 Bun SQLite client service.
When to use
Use to access or provide a Bun SQLite client through the Effect context.
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 Bun SqliteClient values.
Signature
declare const TypeId: "~@effect/sql-sqlite-bun/SqliteClient"Since v4.0.0
TypeId (type alias)
Section titled “TypeId (type alias)”Type-level identifier used to mark Bun SqliteClient values.
Signature
type TypeId = "~@effect/sql-sqlite-bun/SqliteClient"Since v4.0.0