{"id":41684,"library":"orchid-orm","title":"Orchid ORM","description":"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.","status":"active","version":"1.70.1","language":"javascript","source_language":"en","source_url":"https://github.com/romeerez/orchid-orm","tags":["javascript","orm","pg","postgres","ts","typescript"],"install":[{"cmd":"npm install orchid-orm","lang":"bash","label":"npm"},{"cmd":"yarn add orchid-orm","lang":"bash","label":"yarn"},{"cmd":"pnpm add orchid-orm","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; required for type definitions and type inference features.","package":"typescript","optional":false}],"imports":[{"note":"ESM-only package; CommonJS require() will fail.","wrong":"const orchid = require('orchid-orm')","symbol":"orchid-orm","correct":"import { createORM } from 'orchid-orm'"},{"note":"createORM is exported from the main package, not a subpath.","wrong":"import { createORM } from 'orchid-orm/core'","symbol":"createORM","correct":"import { createORM } from 'orchid-orm'"},{"note":"table is a named export, not a subpath import.","wrong":"import { table } from 'orchid-orm/table'","symbol":"table","correct":"import { table } from 'orchid-orm'"},{"note":"Type helpers are exported from the main package as named types.","wrong":"import { InferSelect } from 'orchid-orm/types'","symbol":"type helpers","correct":"import { InferSelect, InferInsert } from 'orchid-orm'"}],"quickstart":{"code":"import { createORM, table } from 'orchid-orm';\n\n// Define a table schema (type-safe)\nconst User = table('user', {\n  columns: {\n    id: { type: 'serial', primary: true },\n    name: { type: 'varchar', length: 100, default: '' },\n    email: { type: 'varchar', length: 255, unique: true },\n  },\n});\n\n// Create ORM instance\nconst orm = createORM({\n  databaseURL: process.env.DATABASE_URL ?? 'postgres://localhost:5432/mydb',\n});\n\n// CRUD operations with full type inference\nasync function main() {\n  const user = await orm(User).insert({ name: 'Alice', email: 'alice@example.com' });\n  // user has type: { id: number; name: string; email: string }\n  const found = await orm(User).where({ email: 'alice@example.com' }).first();\n  console.log(found);\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Demonstrates table definition with type-safe columns and basic insert/query using Orchid ORM with full TypeScript inference."},"warnings":[{"fix":"Update to >=1.55.0 where behavior is consistent: always returns array for multiple inserts, single object for single insert.","message":"In v1.50.0, the return type of `insert` changed from an array to a single record when inserting one row.","severity":"breaking","affected_versions":">=1.50.0 <1.55.0"},{"fix":"Replace `databaseURL` with `connectionString` in configuration.","message":"In v1.60.0, `createORM({ databaseURL })` deprecated in favor of `createORM({ connectionString })`.","severity":"deprecated","affected_versions":">=1.60.0"},{"fix":"Use dynamic import() if needed, or switch to ESM.","message":"Using `require('orchid-orm')` with CommonJS will throw a SyntaxError because the package is ESM-only.","severity":"gotcha","affected_versions":"all"},{"fix":"Set `\"strict\": true` in your tsconfig.json.","message":"TypeScript strict mode is required for full type inference; without it, many types resolve to `any`.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.70.1':20 'belongsto':42 'besid':78 'builder':31 'built':37 'built-in':36 'check':97 'class':88 'compil':68 'compile-tim':67 'complex':99 'current':17 'databas':58 'definit':65 'depend':77,83 'develop':15 'differenti':27 'ensur':66 'esm':89 'etc':44 'exact':54 'experi':16 'express':29 'first':6,87 'first-class':86 'focus':9 'frequent':23 'full':33 'generat':53 'hasmani':43 'high':28 'infer':35 'interact':101 'introspect':61 'javascript':105 'key':26 'manag':48 'mani':50 'manual':63 'migrat':45 'orchid':1 'orm':2,8,51,106 'peer':82 'perform':13,104 'pg':107 'postgr':108 'postgresql':7 'project':93 'provid':85 'queri':30,72 'relat':41 'releas':21 'requir':94 'return':55 'robust':95 'runtim':76 'sacrif':103 'safeti':12,70 'schema':59 'ship':73 'sql':100 'stabl':18 'suitabl':91 'support':39,90 'tabl':64 'time':69 'transact':47 'ts':109 'type':11,34,56,96 'typescript':5,79,110 'typescript-first':4 'unlik':49 'updat':24 'version':19 'via':60 'weekly/biweekly':25 'without':102 'zero':75","created_at":"2026-06-04T18:53:36.603439+00:00","updated_at":"2026-06-04T18:53:36.603439+00:00","problems":[{"fix":"Install orchid-orm: `npm install orchid-orm`; ensure `typescript` is installed as a peer dependency; verify import path is correct.","cause":"Missing TypeScript types or incorrect import usage.","error":"Cannot find module 'orchid-orm' or its corresponding type declarations."},{"fix":"Switch to ESM (use `import` syntax) or use dynamic import: `const orchid = await import('orchid-orm')`.","cause":"CommonJS require() used on an ESM-only package.","error":"SyntaxError: Unexpected token 'export'"},{"fix":"Enable `strict` mode in tsconfig.json and ensure all columns have a valid type and constraints.","cause":"Missing or incorrect type definition for table columns, often due to non-strict TypeScript mode.","error":"Type '...' is not assignable to type 'never'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://orchid-orm.netlify.app/guide/orm-and-query-builder.html","github":"https://github.com/romeerez/orchid-orm","docs":null,"changelog":null,"pypi":null,"npm":"orchid-orm","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}