UQL ORM is a fast, type-safe TypeScript Object-Relational Mapper (ORM) designed with a JSON-native query protocol. Currently at version 0.9.0, it aims for universal compatibility, running across Node.js, Bun, Deno, Cloudflare Workers, Electron, React Native, and browsers. It provides a unified API for various SQL and NoSQL databases, including PostgreSQL, MySQL, MariaDB, SQLite, LibSQL, Neon, D1, and MongoDB. Key differentiators include 100% serializable queries, deeply type-safe APIs for intelligent auto-completion, multi-level operators, and robust support for advanced features like semantic search. While still pre-1.0, the project shows active development with frequent updates and a strong focus on performance and developer experience, offering both decorator-based and imperative entity definition styles.
npm install uql-ormVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates defining a User entity with decorators, connecting to a PostgreSQL database using a querier pool, syncing the schema (caution: drops table), creating a new user, and performing a filtered query to fetch users by name. It also highlights necessary TypeScript compiler options.
Consult the official UQL documentation and release notes for migration guides when updating. Pin exact versions in production (`~0.x.y` rather than `^0.x.y`).
Add or ensure the following in `compilerOptions` in your `tsconfig.json`: `{ "experimentalDecorators": true, "emitDecoratorMetadata": true }`. Alternatively, use the imperative `defineEntity` API which does not require these flags.Ensure your `tsconfig.json` (for TypeScript) or `package.json` (for Node.js) specifies ESM. For TypeScript, set `"module": "NodeNext"`, `"moduleResolution": "NodeNext"`, `"target": "ES2022"` or similar. For Node.js, ensure `"type": "module"` in `package.json` or use `.mjs` file extensions.
Install the appropriate driver package(s) for your chosen database(s). For example, `npm install uql-orm pg` for PostgreSQL.
For new projects or if encountering decorator issues, consider using the `defineEntity` API. For existing projects relying on decorators, ensure your `tsconfig.json` is correctly configured as per `tsconfig.json` warnings.
Add `"experimentalDecorators": true` and `"emitDecoratorMetadata": true` to your `tsconfig.json` under `compilerOptions`.
Configure your project to use ECMAScript Modules (ESM). For TypeScript, set `"module": "NodeNext"` and `"moduleResolution": "NodeNext"` in `tsconfig.json`. For Node.js, ensure `"type": "module"` in `package.json`.
Verify all connection parameters (host, port, user, password, database). Ensure you have installed the correct database driver (e.g., `npm install pg` for PostgreSQL) and that its version is compatible with your Node.js runtime and UQL.
Ensure `"emitDecoratorMetadata": true` is set in your `tsconfig.json` under `compilerOptions`.