uql-orm
v0.56.0
Published
The JSON-native TypeScript ORM for Bun, Browsers, Edge, Deno, Node, Workers. Supports PostgreSQL, PGlite, MySQL, MariaDB, SQLite, CockroachDB, SQL Server, Turso, Neon, Cloudflare D1 and MongoDB. Queries are plain JSON, typed to the leaf.
Maintainers
Keywords
Readme
npm install uql-orm pg # or mysql2, mariadb, better-sqlite3, mongodb, @tursodatabase/serverless, @libsql/clientThat is the whole install (setup). No compiler flags and no reflect-metadata; the decorators are the TC39 standard spec, and plain classes work too, via defineEntity.
Our type-safety automatically prevents the bugs above, without codegen: the entity classes are the schema, pure TypeScript power. That demo editor is on the home page.
The query is just JSON: build it dynamically, store it, diff it, or send it from the browser to the server. The same object runs on every supported database.
Why UQL?
- Serializable queries (JSON), not method chains. Plain JSON in, typed rows out. No DSL to learn.
- One API, everywhere it runs. PostgreSQL, PGlite, CockroachDB, MySQL, MariaDB, MSSQL, SQLite, Turso, libSQL, Neon, Cloudflare D1, Bun's native SQL, and even MongoDB. The same code on Node 24+, Bun, Deno, Cloudflare Workers, AWS Lambda and Vercel, and the browser, with no native binaries on the
fetch-based drivers. - Type-safe to the leaf, nothing to generate. Every key is checked against your entity, down into populated relations and JSON/JSONB dot-paths, so
$likeon a numeric column is a compile error. Entities are plain classes on the standard TC39 decorators: no.prismafile, no generated client, noreflect-metadata, noexperimentalDecorators. - Relations without N+1.
$populateloads a to-many with one query for all parents, not one per parent. Nothing is lazy, so nothing fires behind your back in a serializer. - Migrations you read before they run. Edit an entity, run
uql-migrate generate:entities, review the SQL in the PR like any other file.drift:checkcatches a database that no longer matches. - Raw SQL when you want it.
raw()fits anywhere in a query, computed fields are expressions you can filter on, and a migration can be plain SQL. - Light. Zero runtime dependencies, under 280 kB on the wire, every dialect included. See what we deleted to get there.
- The hard things are built in. Semantic and vector search, multi-tenant filters you cannot bypass by accident, soft-delete with restore, streaming, and a REST API from your entities.
- The fastest ORM. On a full PostgreSQL round trip it adds the least over hand-written driver code of any ORM in our open-source benchmark, by 2.6-3x over the next closest and roughly 10x over the slowest, on Bun, Node and Deno alike. The same benchmark scores the types by writing ten ordinary mistakes in six ORMs' APIs and compiling them: UQL is the only one that catches all ten.
Get started
uql-orm.dev has the full docs. Good places to start:
- Quick Start - install, define an entity, run a query
- Querying - operators, relations, aggregates, transactions
- Entities - decorators, relations, hooks, or the decorator-free imperative API
- Switching to UQL - coming from Prisma, Drizzle, TypeORM, or MikroORM
Release notes live in CHANGELOG.md.
⭐ Like what we're doing? Give us a star
It is how other people find the project.
