Skip to content

LiteORM documentation

LiteORM is a Go data-access library with two front-ends over one CGo-free core: an explicit, generics-first query builder and a declarative, convention-driven orm. Both run against the same backends, the same transaction, and the same normalized errors — so you use orm for CRUD and drop to query for a hot path on the same connection without changing libraries.

New here? Start with Getting started, then pick the front-end that fits the task. Coding with an AI assistant? Set it up first with AI agents & skills so it writes correct LiteORM from the start. Coming from gorm? Map what you know in Coming from gorm.

Start here

  • Cheat sheet — the whole API surface on one screen, each row linking to its guide.
  • Recipes — copy-paste solutions for the common tasks (pagination, bulk insert, upsert, streaming, retries…).
  • Coming from gorm — the verb-for-verb map and what’s intentionally different.

Querying & models

  • Query builderquery.Select[T], typed predicates, joins, unions, subqueries, streaming, the Repo, and the raw escape hatch.
  • ORM models — declarative structs, tags, AutoMigrate, the Repo, conventions.
  • Associations — has-many / has-one / belongs-to / many-to-many with N+1-safe eager loading.
  • Hooks — typed, context-first lifecycle hooks.
  • Soft delete — tri-state scopes and the unique-index behavior.
  • Transactions — savepoints and queryorm interop on one transaction.

Operations

  • Migrations — additive AutoMigrate, reviewable diffs, and the migration runner.
  • Errors — normalized sentinels that work the same across every backend.
  • Statement logging & debugging — watch every executed SQL statement, traced to the Go line that issued it, via slog or a colored handler.
  • Code generation — typed columns, models from a live database, SQL→typed-Go, the sqlc plugin, and the gorm porter.

Backend-specific

  • SQLite search — vector, full-text, and hybrid (reciprocal-rank-fusion) search.
  • At-rest encryption — open an encrypted SQLite database; the on-disk file is ciphertext, readable only with the key.
  • SQLite changesets — capture, apply, invert, and concat changesets for audit and replication.
  • Postgres — LISTEN/NOTIFY and the typed JSONB / array operators.

Tooling

  • Studio — the embedded database studio: a browser admin GUI mounted as an http.Handler.
  • AI agents & skills — set up your AI coding assistant with the shipped Agent Skills so it writes correct LiteORM the first time.
  • Cheat sheet — every Repo method, query terminal, error sentinel, and migrate verb at a glance.
  • Backends — opening each backend, DSN shapes, and the per-dialect capability matrix.
  • Dialects — placeholder styles, identifier quoting, feature flags, and dialect quirks.
  • Supported Go — the supported-release policy.

The complete, always-current API is on pkg.go.dev/liteorm.org — and per package: query, orm, migrate, gen, dialect/sqlite.

LiteORM ships first-class support for AI coding assistants — see AI agents & skills for the full setup. In short: if you’re an assistant building with LiteORM, load the task recipes in skills/; if you’re working inside this repository, read AGENTS.md.