drizzle-orm
Drizzle ORM
Overview
Drizzle ORM is a lightweight, type-safe TypeScript ORM that maps directly to SQL for PostgreSQL, MySQL, and SQLite. It provides both a SQL-like query builder and a relational queries API, with zero dependencies and full serverless compatibility. Use Drizzle when you need compile-time type safety with SQL-level control; avoid it when you need a full active-record ORM with automatic migrations (use Prisma) or when working with MongoDB/NoSQL databases.
Quick Reference
| Pattern | API | Key Points |
|---|---|---|
| Schema definition | pgTable('name', { columns }, (t) => [indexes]) |
Third arg returns array of indexes/constraints |
| Column types | text(), integer(), boolean(), timestamp() |
Import from drizzle-orm/pg-core |
| Type inference | typeof table.$inferSelect, $inferInsert |
Derive TS types directly from schema |
| Relational queries | db.query.table.findMany({ with, where }) |
Requires schema passed to drizzle() client |
| SQL-like queries | db.select().from(table).where() |
Chainable, returns array of rows |
| Insert | db.insert(table).values({}).returning() |
.returning() for getting inserted rows |
| Update | db.update(table).set({}).where().returning() |
Always include .where() to avoid full-table updates |
| Delete | db.delete(table).where() |
Always include .where() to avoid full-table deletes |
| Upsert | .onConflictDoUpdate({ target, set }) |
Chain after .insert().values() |
More from oakoss/agent-skills
playwright
|
200ui-ux-polish
Iterative UI/UX polishing workflow for web applications. Use when improving visual polish, refining desktop and mobile UX separately, running iterative enhancement cycles, applying design patterns like glassmorphism or bento grids, or auditing accessibility and WCAG compliance. Use for Stripe-level visual quality, responsive optimization, and design system alignment.
153find-skills
|
119knowledge-graph-builder
>
101tailwind
Tailwind CSS v4 patterns and design systems. Use when configuring Tailwind themes, building components, implementing dark mode, using container queries, migrating from v3, integrating shadcn/ui, or fixing build errors. Use for tailwind, css, styling, theme, design-tokens.
85pnpm-workspace
pnpm workspace monorepo management with filtering, catalogs, and shared configs. Use when setting up monorepos, managing workspace dependencies, filtering package commands, or sharing configuration across packages.
78