Use Drizzle ORM with DaloyJS
Drizzle ORM is a lightweight, TypeScript-native ORM with a SQL-like API. It runs everywhere DaloyJS does, including Cloudflare Workers, and infers result types directly from your schema.
- 01clientHTTP requestGET /users/:id
- 02zodValidated inputparams.id is a uuid
- 03drizzleTyped queryselect().from(users).where(eq(...))
- 04responseTyped body200 UserSchema | 404
1. Install
2. Define your schema
3. Create a Drizzle plugin
4. Augment app state types
Add the declare module block to the same module that exports db, 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.
5. Use it in routes
Transactions
Edge runtimes
Drizzle is the easiest path to running DaloyJS against a real database on the edge. Pick a driver:
- Cloudflare Workers + D1:
drizzle-orm/d1 - Neon (Postgres) on any edge:
drizzle-orm/neon-http - PlanetScale (MySQL):
drizzle-orm/planetscale-serverless
Compare with Prisma, TypeORM, MikroORM, Sequelize, or the ODM overview if you are working with document databases.
Drizzle pairs cleanly with every host in the database hosting overview, including Neon, PlanetScale, Turso, and Cloudflare D1.