mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-28 19:14:53 +00:00
17 lines
783 B
TypeScript
17 lines
783 B
TypeScript
import { SQLiteError } from "bun:sqlite"
|
|
import { SqliteClient } from "@effect/sql-sqlite-bun"
|
|
import { Layer } from "effect"
|
|
import type { SqlClient } from "effect/sql"
|
|
|
|
export const supportsTuningPragmas = true
|
|
|
|
// Foreign keys default OFF and can be toggled per connection.
|
|
export const supportsForeignKeyToggle = true
|
|
|
|
// Opening the database can only fail on a broken file or a lock held past
|
|
// busyTimeout; Database.layer treats both as fatal.
|
|
export const sqliteLayer = (config: SqliteClient.SqliteClientConfig): Layer.Layer<SqlClient.SqlClient> =>
|
|
Layer.orDie(SqliteClient.layer(config))
|
|
|
|
// bun:sqlite throws SQLiteError, whose errno is SQLite's extended result code.
|
|
export const resultCode = (cause: unknown) => (cause instanceof SQLiteError ? cause.errno : undefined)
|