Generate Drizzle ORM query functions for database operations
Generates a Drizzle ORM query module with typed functions for CRUD operations on a database table. Query functions are plain async functions designed to be called from React Query hooks.
/new-db-query getTransactions # db/queries/transactions.ts
/new-db-query getBudgets # db/queries/budgets.ts
/new-db-query getCategories # db/queries/categories.ts
| Argument | Required | Description |
|----------|----------|-------------|
| name | Yes | Primary function name (e.g., getTransactions) |
The entity name is derived from the function name by removing the get prefix
and converting to lowercase.
Place the query module at:
db/queries/<entity>.ts
Look for the table definition in db/schema.ts. If the table does not exist,
inform the user it needs to be added first.
Create the module with:
get<Entity>s() -- fetch all records (with ordering)get<Entity>ById(id) -- fetch a single recordcreate<Entity>(data) -- insert a new recordupdate<Entity>(data) -- update an existing recorddelete<Entity>(id) -- delete a recordSee references/db-query-examples.md for templates.
npx tsc --noEmit
All database query functions MUST live in db/queries/. They must NOT be defined
inside React Query hooks, components, or stores.
async functions (not hooks)T | null (not throwing)Default ordering should be desc(createdAt) for most entities.
import { eq, desc, and, or, like, gte, lte, sql } from 'drizzle-orm';
import { db } from '../client';
import { tableName, type NewTableType } from '../schema';
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer