Skip to content

Quick Start

UQL is the JSON-native query protocol for TypeScript. It is engineered to be fast, safe, and universally compatible.

  • Runs Everywhere: Node.js, Bun, Deno, Cloudflare Workers, Electron, React Native, and the Browser.
  • Unified API: A consistent interface for PostgreSQL, MySQL, MariaDB, SQLite, LibSQL, Neon, D1, and MongoDB.

Install the core and your preferred driver:

Terminal window
npm install uql-orm pg # or mysql2, better-sqlite3, mongodb, etc.

Here is a complete example of defining an entity, setting up a pool, and running a query.

entities.ts
import { Entity, Id, Field } from 'uql-orm';
@Entity()
export class User {
@Id({ type: 'uuid' })
id?: string;
@Field({ unique: true })
email?: string;
@Field()
name?: string;
}
// uql.config.ts
import type { Config } from 'uql-orm';
import { PgQuerierPool } from 'uql-orm/postgres';
import { User } from './entities.js';
const pool = new PgQuerierPool({ host: 'localhost', database: 'uql_app' });
export default { pool, entities: [User] } satisfies Config;
export { pool };
// app.ts
import { pool } from './uql.config.js';
import { User } from './entities.js';
const users = await pool.transaction(async (querier) => {
return await querier.findMany(User, {
$select: { id: true, name: true },
$where: { email: { $endsWith: '@uql-orm.dev' } },
$limit: 10,
});
});
console.log(users);

DatabaseDriver PackageStatus
Bun SQL Nativebun:sql✅ Full
PostgreSQLpg✅ Full
CockroachDBpg✅ Full
MySQLmysql2✅ Full
MariaDBmariadb or mysql2✅ Full
SQLitebetter-sqlite3✅ Full
LibSQL / Turso@libsql/client✅ Full
Cloudflare D1✅ Full
Neon@neondatabase/serverless✅ Full
MongoDBmongodb✅ Full

UQL uses subpath exports to keep your bundles lean:

PathPurpose
uql-ormCore decorators, types, and query utilities
uql-orm/postgresPostgreSQL driver pool
uql-orm/cockroachCockroachDB driver pool
uql-orm/mysqlMySQL driver pool (also works with MariaDB)
uql-orm/mariaMariaDB driver pool (dedicated mariadb driver)
uql-orm/sqliteSQLite driver pool
uql-orm/bunSqlBun Native SQL driver pool (Postgres, MySQL, SQLite)
uql-orm/libsqlLibSQL / Turso driver pool
uql-orm/neonNeon serverless driver pool
uql-orm/d1Cloudflare D1 driver pool
uql-orm/mongoMongoDB driver pool
uql-orm/expressExpress middleware (auto-generated REST APIs)
uql-orm/browserBrowser HTTP querier
uql-orm/migrateMigration engine & CLI