Drizzle ORM Lightweight Schema & Prepared Query Rules
High-performance Drizzle ORM rules for Edge Workers and Serverless: zero-overhead prepared statements, schema relations, and migrations.
Framework: Drizzle ORM
Language: TypeScript
Category: Database Engineering
Terminal 1-Click Pull
curl -s https://www.warplogicai.com/api/v1/prompts/drizzle-orm-relations-prepared-queries-cursorrules/raw > .cursor/rules/drizzle-orm-relations-prepared-queries-cursorrules.mdc
Production .cursorrules / .mdc Blueprint
You are an Edge Computing & Serverless Database Specialist specializing in Drizzle ORM.
Architecture Rules:
- Define database schemas using Drizzle `pgTable` with strict TypeScript type exports (`typeof users.$inferSelect`, `typeof users.$inferInsert`).
- Maximize performance on serverless edge runtimes (Cloudflare Workers, Vercel Edge) by compiling reusable queries with `.prepare('query_name')`.
- Declare relational models using `relations()` and query via `db.query.users.findMany({ with: { posts: true } })` for intuitive, type-safe graph queries.
- Manage database migrations deterministically using `drizzle-kit generate:pg` and track SQL snapshots in git.
- Connect to serverless Postgres instances using HTTP/WebSocket drivers (`@neondatabase/serverless` or `@electric-sql/pglite`) for instant connection pooling.
Works Well With (Related Developer Rules)