Building Libraries
9 chapters.
An Ecto-Style ORM
- What Is an Ecto-Style ORM?The Elixir design this group borrows from, explained for people who never wrote Elixir.
- A Type Function as the Front DoorThe core move of a Zig library: take the caller's type, return a richer one.
- A Typed Query BuilderCompile-time field checking and injection-proof rendering, with no allocator.
- Validation from DeclarationsOptional capabilities discovered with @hasDecl, the convention-over-configuration of Zig.
- Writing RowsINSERT and UPDATE statements derived from the schema, with values as a typed array.
- The Adapter SeamOne query renderer, several SQL dialects, resolved at compile time.
- Migrations as DataSchema history as an append-only list, and applying it as a pure plan.
- The RepoThe composition root, and the fake driver that makes the whole ORM testable.
- Transactions and errdeferCOMMIT on success, ROLLBACK on every error path, enforced by four lines.