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.
1. Install
Section titled “1. Install”Install the core and your preferred driver:
npm install @uql/core pg # or mysql2, better-sqlite3, mongodb, etc.2. Fast-Track Example
Section titled “2. Fast-Track Example”Here is a complete example of defining an entity, setting up a pool, and running a query.
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.tsimport { PgQuerierPool } from '@uql/core/postgres';import { User } from './entities.js';
export const pool = new PgQuerierPool( { host: 'localhost', database: 'uql_app' }, { entities: [User] });
// app.tsimport { 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);Next Steps
Section titled “Next Steps”Now that you’ve seen the basics, dive deeper into the core concepts:
- Define Entities: Explore all decorators and type abstractions.
- Define Relations: Map complex relationships with ease.
- 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.