Lite by design, not by omission. LiteORM is lite because it's modern, not minimal — built from a clean Go baseline (generics, iter.Seq2, log/slog, CGo-free pure-Go SQLite) instead of a decade-old codebase patched a thousand times. Being lean is what lets it ship more, not less.
One library, two front-ends over one core: an explicit, generics-first query builder and a declarative, convention-driven orm — same backends, same transaction, same normalized errors. Use orm for CRUD and drop to query for a hot path on the same connection. SQLite is CGo-free (via gosqlite.org) — in-process, or a remote server over the network via quicSQL; Postgres, MySQL, and SQL Server are first-class too. And it's built for how software gets written now — the first Go ORM with an embedded database studio that has AI built in, plus Agent Skills so your AI assistant writes correct LiteORM on the first try.
import (
"liteorm.org/dialect/sqlite"
"liteorm.org/query"
)
db, _ := sqlite.Open("app.db")
defer db.Close()
books, _ := query.Select[Product](db).
Filter(query.And(
query.Col[string]("category").Eq("books"),
query.Col[float64]("price").Lt(40),
)).
OrderBy("price").All(ctx)Most libraries that call themselves lite got there by leaving features out. LiteORM got there by never taking on the weight — no decade of reflection-heavy runtime, no interface{} plumbing, no mandatory CGo, no API grown by accretion. That's what frees it to do more, not less:
-
🧩 Two paradigms, one core — no library lock-in. The
querybuilder (typed, low-magic) and theorm(declarative, tag-driven) share oneSession, one dialect, one scanner, and one set of normalized errors. A row fetched viaormfeedsqueryon the same transaction. Most stacks make you pick a camp; LiteORM lets each part of your app pick the right tool. -
⚡ Modern baseline, lean core. Generics-first: typed result rows and typed
Col[V]predicates, with no reflection on the hot path. The core module pulls in no database drivers — each backend (dialect/sqlite,dialect/postgres,dialect/mysql,dialect/mssql) is its own module, so your build only carries the driver you use. SQLite is pure Go: cross-compile with plaingo build, ship static distroless/alpine binaries, no C toolchain — and open it encrypted at rest with a key, transparent page-level encryption (Adiantum) without a CGo sqlcipher build.iter.Seq2streaming,log/sloglogging, andgopls modernizeenforced in CI keep it from drifting backward. -
🤖 Built for agents — AI-native two ways. The embedded studio turns plain English into SQL through one server-side
WithAIhook to any model, so your API key never reaches the browser — no other Go ORM ships this. Separately, the repo ships Agent Skills and anAGENTS.mdso an AI coding assistant writes correct LiteORM without guessing. AI for the people using your database and the people building against it. -
🎯 Safe by default. No implicit lazy loading — eager
Loadis N+1-safe by construction. Soft-delete is an explicit tri-state scope, not a magic global filter. Constraint and not-found errors normalize to the same sentinels on every backend, so you write the check once. -
⚙️ Codegen on-ramps when you want them. Generate compile-time-safe typed columns, models from a live database, or typed Go functions from annotated SQL — and there's a sqlc plugin and a gorm-tag porter. Opt in per need; the runtime path never requires codegen.
- docs/ — guides and reference. Start at Getting started.
- pkg.go.dev/liteorm.org — the Go API reference.
skills/— task recipes for AI agents using LiteORM;AGENTS.mdfor agents developing it.
- Query builder —
query.Select[T]with typedCol[V]predicates (And/Or/Not,In/Like/IsNull), typedOrder(Asc/Desc) andGroupByCols, typed aggregates (Sum/Avg/Min/Maxand groupedInto), join helpers, set operations (Union/Intersect/Except), CTEs (With/WithRecursive) and subqueryFrom/JoinSub, row locking (ForUpdate/ForShare/SkipLocked),DistinctOn,IN-subqueries andEXISTS,Having,iter.Seq2streaming, a CRUDRepowithUpsertand bulk insert, multi-rowUpdate/Deletebuilders withRETURNINGand correlatedUPDATE … FROM, window functions (RowNumber/Rank/Lag/…) and scalar subqueries in the SELECT list, and aRaw[T]escape hatch. - ORM — declarative models from
orm:""(orgorm:"") tags, additiveAutoMigrate, a CRUD Repo, associations (has-many / has-one / belongs-to / many-to-many) with N+1-safe eager loading, typed hooks (write, save, and theAfterFindread hook), and soft delete with a unique-index fix. - Field codecs — transform a field on read/write — a JSON or gob column, an encrypted or compressed
[]byte— without changing its Go type. Built-injson/gob/unixtime, a type-safecodec.Funcfor your own (no codegen), gormserializer:compatible, and applied in the shared scan layer so it works the same on both front-ends. - Transactions —
liteorm.Transaction(ctx, db, fn)for closure-style commit/rollback, andliteorm.TransactionRetrythat retries the whole unit of work on a normalized serialization/deadlock failure — across every backend. - Observability — one
Observerseam around every statement (SQL, args, timing, rows, error) for OpenTelemetry tracing, metrics, or audit, on a connection or a transaction; the built-inslogstatement logging rides the same event. - Studio + AI — the first Go ORM to ship an embedded database studio: a browser admin GUI (browse, filter, edit, follow foreign keys, run SQL, import/export CSV·JSON·SQL) as a stdlib
http.Handleryou mount behind your own auth. AI is built in — natural-language → SQL, English filters, and automatic result charts via one server-sideWithAIhook to any model. Backend is LiteORM-native (so it knows your relations and types); frontend is the Prisma Studio UI, embedded. - Migrations — additive
AutoMigrateplus a two-track model: destructive changes become a reviewable migration you apply through a thin runner that reads golang-migrate / goose / plain SQL files. - Normalized errors —
ErrUniqueViolation,ErrForeignKey,ErrNotNull,ErrCheck,ErrNoRows,ErrDeadlock,ErrSerialization— the same on SQLite, Postgres, MySQL, and SQL Server. - Code generation — typed
Column[V]constants for compile-time column safety, models from a live DB, SQL→typed-Go from annotated queries, a sqlc process plugin, and a gorm→LiteORM tag porter. - SQLite vector / full-text / hybrid search — typed vector (sqlite-vec) and FTS5 search, plus reciprocal-rank-fusion hybrid search, keyed by your model's primary key.
- At-rest encryption — open an encrypted SQLite database with a 32-byte key: transparent, page-level encryption (Adiantum), pure Go — no CGo sqlcipher. The on-disk file is ciphertext; the
querybuilder,orm, and migrations all work unchanged above it. - SQLite changesets — capture, apply, invert, and concat changesets for audit logs, one-way replication, and undo.
- Postgres extras — LISTEN/NOTIFY and typed JSONB (
->,->>,@>) and array (@>,&&,= ANY) operators.
Read top-down: who LiteORM is, what it's built for, then the capability depth behind it.
| Capability | LiteORM | gorm | bun | sqlc | ent |
|---|---|---|---|---|---|
| Core runtime model | generics, no reflection | reflection | reflection | generated code | generated code |
| Explicit query builder and declarative ORM in one lib | ✓ | ✗ (ORM) | ✓ builder (light ORM) | ✗ (SQL→Go) | ✗ (generated ORM) |
| CGo-free SQLite (pure Go, no C toolchain) | ✓ | driver of choice | driver of choice | driver of choice | driver of choice |
| At-rest encrypted SQLite, pure Go (no CGo sqlcipher) | ✓ | ✗ | ✗ | ✗ | ✗ |
| Ships an embedded database studio (admin GUI) | ✓ | ✗ | ✗ | ✗ | ✗ |
| Studio with built-in AI (NL→SQL, English filters, result charts) | ✓ | ✗ | ✗ | ✗ | ✗ |
| Ships AI Agent Skills + task-oriented docs | ✓ | ✗ | ✗ | ✗ | ✗ |
| Typed joins, set ops, subqueries, CTEs, window functions | ✓ | partial | partial | n/a | ✓ |
| Associations + N+1-safe eager load | ✓ (explicit, no lazy) | ✓ (lazy preload) | ✓ | ✗ | ✓ |
| Normalized errors across all backends | ✓ | ✗ | ✗ | ✗ | ✗ |
| Migrations: additive auto + reviewable destructive | ✓ | ✓ (auto only) | ✓ (files) | ✗ | ✓ |
| Codegen: typed columns / models / SQL→Go + sqlc plugin | ✓ | ✗ | ✗ | ✓ (SQL→Go) | ✓ (schema→code) |
| SQLite vector + FTS5 + hybrid search, changesets | ✓ | ✗ | ✗ | ✗ | ✗ |
Where it's strongest: LiteORM is the only Go library that puts a typed query builder and a declarative ORM over one core — so the wins above (normalized errors on every backend, N+1-safe-by-construction loading, CGo-free SQLite with vector/FTS/hybrid search and changesets, an embedded database studio with built-in AI, shipped Agent Skills) hold across both front-ends, not just one.
By design: LiteORM is runtime-first — typed predicates and clauses cover the everyday SQL surface, with Project / Raw[T] as the escape hatch for the genuinely exotic, rather than a fully-generated DSL like ent. Full compile-time column safety is therefore opt-in through the codegen on-ramp instead of mandatory, and the ecosystem is younger than gorm's or ent's.
import (
"liteorm.org/dialect/sqlite"
"liteorm.org/orm"
"liteorm.org/query"
)
db, _ := sqlite.Open("app.db")
defer db.Close()
// Declarative: tag a model, migrate, CRUD.
type Author struct {
ID int64
Name string
Email string `orm:"email,unique"`
}
func (Author) TableName() string { return "authors" }
_ = orm.AutoMigrate[Author](ctx, db)
authors := orm.NewRepo[Author](db)
ada := Author{Name: "Ada", Email: "ada@example.com"}
_ = authors.Create(ctx, &ada)
// Explicit: typed predicates on the same DB.
hits, _ := query.Select[Author](db).
Filter(query.Col[string]("email").Like("%@example.com")).
OrderBy("name").All(ctx)Full walkthrough in Getting started.
| Import path | What it gives you |
|---|---|
liteorm.org |
core: DB / Session / Tx, normalized error sentinels, capability interfaces (driver-free) |
liteorm.org/query |
the explicit builder: Select[T], typed predicates, Repo[T], Raw[T] |
liteorm.org/orm |
the declarative ORM: models, AutoMigrate, Repo[T], associations, hooks, soft-delete |
liteorm.org/migrate |
the migration runner (Load, Up/Down, WritePair) |
liteorm.org/gen |
codegen: typed columns, models, SQL→Go, the gorm porter |
liteorm.org/dialect/sqlite |
CGo-free SQLite backend, local or remote (quicSQL) (+ /search, /changeset sub-packages) |
liteorm.org/dialect/postgres |
native pgx backend (+ LISTEN/NOTIFY) |
liteorm.org/dialect/mysql · liteorm.org/dialect/mssql |
MySQL · SQL Server backends |
liteorm.org/cmd/sqlc-gen-liteorm |
a sqlc codegen plugin that emits LiteORM runtime code |
| Coming from | Path |
|---|---|
| gorm | your gorm:"..."-tagged models work in orm unchanged; run gen.PortSource to rewrite them to native orm:"..." tags and drop the gorm dependency. Differences: eager loading is explicit (Load), soft-delete uses tri-state scopes. |
| sqlc | keep your annotated .sql files — the sqlc-gen-liteorm plugin emits LiteORM runtime functions from them; or use LiteORM's own annotated-SQL generator. |
| database/sql | open a backend, then use query.Raw[T] for existing SQL and adopt the builder / ORM incrementally on the same *sql-backed connection. |
Runnable, smoke-tested programs under examples/: blog (a small end-to-end blog engine — models, associations, nested eager loading, an aggregate query, and a transaction), query and orm feature showcases, logging (statement tracing), search (vector + full-text + hybrid), encryption (at-rest encrypted SQLite), queries (SQL→Go codegen), gormport (the gorm porter), and codegen. just example <name> runs one; just examples runs them all.
just recipes drive everything: just (build + test + lint), just test, just test-race, just lint, just examples, and just db-up / just test-live for the live cross-dialect conformance suite (any Docker engine). Architecture, invariants, conventions, and where-to-look live in AGENTS.md.
The two most recent Go releases; the exact pin lives in go.mod. See Supported Go.
This project is supported by:
- ssh2incus — an open-source SSH server that connects directly to Incus containers and virtual machines, routing incoming SSH connections to the right instance via the Incus API.
- mobydeck — a GitHub organization publishing open-source developer tools and infrastructure utilities across Go, C, TypeScript, shell, and Ruby.
If your company benefits from this library and you'd like to be listed here, open an issue.
Apache 2.0. See LICENSE.

