Registry / database / orchid-orm

orchid-orm

JSON →
library1.70.1jsnpmunverified

A TypeScript-first PostgreSQL ORM focused on type safety, performance, and developer experience. Current stable version 1.70.1, released with frequent updates (weekly/biweekly). Key differentiators: highly expressive query builder with full type inference, built-in support for relations (belongsTo, hasMany, etc.), migrations, and transaction management. Unlike many ORMs, it generates exact return types from database schema via introspection or manual table definitions, ensuring compile-time safety for queries. Ships with zero runtime dependencies besides TypeScript as a peer dependency, and provides first-class ESM support. Suitable for projects requiring robust type checking and complex SQL interactions without sacrificing performance.

npm install orchid-orm
INSTALL
IMPORT
SIG · ORCHID-ORM
O
orchid-orm
databasejavascriptv1.70.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

orchid-orm
import { createORM } from 'orchid-orm'
const orchid = require('orchid-orm')
ESM-only package; CommonJS require() will fail.
createORM
import { createORM } from 'orchid-orm'
import { createORM } from 'orchid-orm/core'
createORM is exported from the main package, not a subpath.
table
import { table } from 'orchid-orm'
import { table } from 'orchid-orm/table'
table is a named export, not a subpath import.
type helpers
import { InferSelect, InferInsert } from 'orchid-orm'
import { InferSelect } from 'orchid-orm/types'
Type helpers are exported from the main package as named types.

Demonstrates table definition with type-safe columns and basic insert/query using Orchid ORM with full TypeScript inference.

import { createORM, table } from 'orchid-orm'; // Define a table schema (type-safe) const User = table('user', { columns: { id: { type: 'serial', primary: true }, name: { type: 'varchar', length: 100, default: '' }, email: { type: 'varchar', length: 255, unique: true }, }, }); // Create ORM instance const orm = createORM({ databaseURL: process.env.DATABASE_URL ?? 'postgres://localhost:5432/mydb', }); // CRUD operations with full type inference async function main() { const user = await orm(User).insert({ name: 'Alice', email: 'alice@example.com' }); // user has type: { id: number; name: string; email: string } const found = await orm(User).where({ email: 'alice@example.com' }).first(); console.log(found); } main().catch(console.error);
Debug
Known issues
breakingIn v1.50.0, the return type of `insert` changed from an array to a single record when inserting one row.
fix
Update to >=1.55.0 where behavior is consistent: always returns array for multiple inserts, single object for single insert.
affects: >=1.50.0 <1.55.0
deprecatedIn v1.60.0, `createORM({ databaseURL })` deprecated in favor of `createORM({ connectionString })`.
fix
Replace `databaseURL` with `connectionString` in configuration.
affects: >=1.60.0
gotchaUsing `require('orchid-orm')` with CommonJS will throw a SyntaxError because the package is ESM-only.
fix
Use dynamic import() if needed, or switch to ESM.
affects: all
gotchaTypeScript strict mode is required for full type inference; without it, many types resolve to `any`.
fix
Set `"strict": true` in your tsconfig.json.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'orchid-orm' or its corresponding type declarations.
Missing TypeScript types or incorrect import usage.
fix
Install orchid-orm: `npm install orchid-orm`; ensure `typescript` is installed as a peer dependency; verify import path is correct.
SyntaxError: Unexpected token 'export'
CommonJS require() used on an ESM-only package.
fix
Switch to ESM (use `import` syntax) or use dynamic import: `const orchid = await import('orchid-orm')`.
Type '...' is not assignable to type 'never'.
Missing or incorrect type definition for table columns, often due to non-strict TypeScript mode.
fix
Enable `strict` mode in tsconfig.json and ensure all columns have a valid type and constraints.
Upgrade
Version history
1.70.1latest on npm
Audit
Dependencies
typescriptrequiredPeer dependency; required for type definitions and type inference features.
Agent activity
4 hits · last 30 days
node
4
Resources
orchid-orm — npm install orchid-orm · libregistry