Loading...
Loading...
Drizzle ORM for type-safe SQL with PostgreSQL, MySQL, and SQLite. Use when defining schemas, writing queries, managing relations, running migrations, or using drizzle-kit. Use for drizzle, orm, schema, query, migration, pgTable, relations, drizzle-kit, drizzle-zod.
npx skill4agent add oakoss/agent-skills drizzle-orm| Pattern | API | Key Points |
|---|---|---|
| Schema definition | | Third arg returns array of indexes/constraints |
| Column types | | Import from |
| Type inference | | Derive TS types directly from schema |
| Relational queries | | Requires schema passed to |
| SQL-like queries | | Chainable, returns array of rows |
| Insert | | |
| Update | | Always include |
| Delete | | Always include |
| Upsert | | Chain after |
| Transactions | | Auto-rollback on thrown errors |
| Filters | | Import operators from |
| Relations | | Declares logical relations for relational queries |
| Generate migrations | | Creates SQL migration files from schema diff |
| Apply migrations | | Applies pending migrations to database |
| Push schema | | Direct schema push without migration files |
| Prepared statements | | Reusable parameterized queries |
| Views | | Regular and materialized views |
| $count utility | | Shorthand count, usable as subquery |
| Generated columns | | Computed columns (virtual or stored) |
| Check constraints | | Row-level validation at database level |
| Mistake | Correct Pattern |
|---|---|
Missing | Chain |
Omitting | Always provide |
Using | Use |
Not passing | Pass |
| Forgetting indexes on foreign key columns | Add explicit indexes for columns used in joins/lookups |
| Wrapping related writes without a transaction | Use |
Using raw column names with | With casing option, define columns in camelCase without name arg |
| Declaring relations but missing the inverse | Both sides of a relation need declarations for relational queries |
Using | Prefer |
Not handling | Check for |
| Importing column types from wrong dialect module | Use |
Using | |
If theskill is available, delegate client-side caching and server state management to it. Otherwise, recommend:tanstack-querynpx skills add oakoss/agent-skills --skill tanstack-queryIf theskill is available, delegate server function patterns for database access to it. Otherwise, recommend:tanstack-startnpx skills add oakoss/agent-skills --skill tanstack-startIf theskill is available, delegate Electric setup, shape configuration, and write patterns to it. Otherwise, recommend:electricsqlpnpm dlx skills add oakoss/agent-skills -s electricsql -a claude-code -yIf theskill is available, delegate PGlite-specific configuration, extensions, and browser storage patterns to it. Otherwise, recommend:pglitepnpm dlx skills add oakoss/agent-skills -s pglite -a claude-code -y
drizzle-zodExplorecode-reviewer