Skip to content

Quick Start

UQL is the smartest ORM 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/core 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, Relation } from '@uql/core';
@Entity()
export class User {
@Id({ type: 'uuid' })
id?: string;
@Field({ unique: true })
email?: string;
@Field()
name?: string;
}
// uql.config.ts
import { PgQuerierPool } from '@uql/core/postgres';
import { User } from './entities.js';
export const pool = new PgQuerierPool(
{ host: 'localhost', database: 'uql_app' },
{ entities: [User] }
);
// 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', 'name'],
$where: { email: { $endsWith: '@uql.app' } },
$limit: 10,
});
});
console.log(users);

Now that you’ve seen the basics, dive deeper into the core concepts:

  • Querying: Learn about deep selection, filtering, and sorting.
  • Transactions: Master automatic and manual transaction patterns.
  • Migrations: Manage your schema evolution with the CLI and Drift Detection.