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.fixUpdate 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 })`.fixReplace `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.fixUse 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`.fixSet `"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.
fixInstall 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.
fixSwitch 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.
fixEnable `strict` mode in tsconfig.json and ensure all columns have a valid type and constraints.
Audit
Dependencies
typescriptrequiredPeer dependency; required for type definitions and type inference features.