Use TypeORM with DaloyJS
TypeORM gives you decorator-based entities and the active-record / data-mapper patterns familiar to Java and .NET teams. It runs best on the Node.js adapter.
- 01clientHTTP requestGET /users/:id
- 02zodValidated inputparams.id is a uuid
- 03typeormRepository querygetRepository(User).findOneBy(...)
- 04responseTyped body200 UserSchema | 404
1. Install
TypeORM relies on reflect-metadata and decorator metadata. Make sure your tsconfig.json enables them:
2. Define an entity
3. Configure the DataSource
4. Create a TypeORM plugin
5. Augment app state types
Add the declare module block to the same module that creates the plugin, not to a separate .d.ts file. Declaration files are exempt from type-checking when skipLibCheck is on (the scaffolded default), so a broken import inside a .d.ts fails silently and state.db quietly degrades to any.
6. Use repositories in routes
Transactions
Migrations
Runtime notes
- TypeORM uses Node-only APIs (filesystem, native drivers). It does not run on Cloudflare Workers, use Drizzle or Supabase there.
- On Bun and Deno, prefer
drizzle-style postgres clients unless you need TypeORM's decorators. - Always import
reflect-metadataonce at the entrypoint, before anything else.
Compare with Prisma, Drizzle, MikroORM, Sequelize, or the ODM overview if you need document models.