Skip to content

SqliteClient.ts

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



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>

Source

Since v4.0.0

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>

Source

Since v4.0.0

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>

Source

Since v4.0.0

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
}

Source

Since v4.0.0

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
}

Source

Since v4.0.0

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>

Source

Since v4.0.0

Runtime type identifier used to mark Bun SqliteClient values.

Signature

declare const TypeId: "~@effect/sql-sqlite-bun/SqliteClient"

Source

Since v4.0.0

Type-level identifier used to mark Bun SqliteClient values.

Signature

type TypeId = "~@effect/sql-sqlite-bun/SqliteClient"

Source

Since v4.0.0