ADR 0012: @arachnejs/db + dialect packages
- Status: Accepted
- Date: 2026-09-28
- Deciders: Arachne core
Context #
“One schema, many outputs” needs a persistence layer that validates with
@arachnejs/schema and talks to real databases without locking the core to a
single driver.
Decision #
@arachnejs/dbowns:column.*/defineTable— columns pair SQL types with Standard SchemacreateDb({ dialect, tables })— typedinsert/select/deletesync()—CREATE TABLE IF NOT EXISTSfrom table defs- Dialect interface (
exec/all/close)
- Driver packages (
@arachnejs/db-sqlite, later postgres/mysql/mongo) implement the dialect. Phase 0 ships SQLite viabun:sqlite. - Query surface is intentionally small (equality
where, no joins yet). Richer SQL builders land later without changingdefineTable.
Alternatives considered #
- Drizzle / Kysely as the public API — rejected; wrong package boundary.
- ORM-only with no raw dialect — rejected; dialects must stay swappable.
Consequences #
- Apps depend on
@arachnejs/db+ one@arachnejs/db-*driver. - Migrations package (
@arachnejs/migrate) will consume the same table defs.