
using-drizzle-queries
Write type-safe database queries with Drizzle ORM. Covers select, insert, update, delete, relational queries, and adding new tables.
- Installs
- 135
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/andrelandgraf/fullstackrecipes --skill using-drizzle-queries- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads using-drizzle-queries automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Working with Drizzle
Write type-safe database queries with Drizzle ORM. Covers select, insert, update, delete, relational queries, and adding new tables.
Implement Working with Drizzle
Write type-safe database queries with Drizzle ORM. Covers select, insert, update, delete, relational queries, and adding new tables.
See:
- Resource:
using-drizzle-queriesin Fullstack Recipes - URL: https://fullstackrecipes.com/recipes/using-drizzle-queries
Writing Queries
Use Drizzle's query API for type-safe database operations:
import { db } from "@/lib/db/client";
import { chats } from "@/lib/chat/schema";
import { eq, desc } from "drizzle-orm";
// Select all
const allChats = await db.select().from(chats);
// Select with filter
const userChats = await db
.select()
.from(chats)
.where(eq(chats.userId, userId))
.orderBy(desc(chats.createdAt));
// Select single record
const chat = await db
.select()
.from(chats)
.where(eq(chats.id, chatId))
.limit(1)
.then((rows) => rows[0]);
Inserting Data
import { db } from "@/lib/db/client";
import { chats } from "@/lib/chat/schema";
// Insert single record
const [newChat] = await db
.insert(chats)
.values({
userId,
title: "New Chat",
})
.returning();
// Insert multiple records
await db.insert(messages).values([
{ chatId, role: "user", content: "Hello" },
{ chatId, role: "assistant", content: "Hi there!" },
]);
Updating Data
import { db } from "@/lib/db/client";
import { chats } from "@/lib/chat/schema";
import { eq } from "drizzle-orm";
await db
.update(chats)
.set({ title: "Updated Title" })
.where(eq(chats.id, chatId));
Deleting Data
import { db } from "@/lib/db/client";
import { chats } from "@/lib/chat/schema";
import { eq } from "drizzle-orm";
await db.delete(chats).where(eq(chats.id, chatId));
Using Relational Queries
For queries with relations, use the query API:
import { db } from "@/lib/db/client";
const chatWithMessages = await db.query.chats.findFirst({
where: eq(chats.id, chatId),
with: {
messages: {
orderBy: (messages, { asc }) => [asc(messages.createdAt)],
},
},
});
Adding New Tables
- Create the schema in the feature's library folder:
// src/lib/feature/schema.ts
import { pgTable, text, uuid, timestamp } from "drizzle-orm/pg-core";
export const items = pgTable("items", {
id: uuid("id").primaryKey().defaultRandom(),
name: text("name").notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
});
- Import the schema in
src/lib/db/client.ts:
import * as itemSchema from "@/lib/feature/schema";
const schema = {
...authSchema,
...chatSchema,
...itemSchema,
};
- Generate and run migrations:
bun run db:generate
bun run db:migrate
References
FAQ
What does the using-drizzle-queries skill do?
Write type-safe database queries with Drizzle ORM. Covers select, insert, update, delete, relational queries, and adding new tables.
How do I install using-drizzle-queries?
Run npx skills add https://github.com/andrelandgraf/fullstackrecipes --skill using-drizzle-queries in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/using-drizzle-queries/ (personal) or .claude/skills/using-drizzle-queries/ (project).
Which AI agents can use using-drizzle-queries?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is using-drizzle-queries safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains using-drizzle-queries?
It is published by andrelandgraf in andrelandgraf/fullstackrecipes. It has 135 recorded installs.
More from andrelandgraf/fullstackrecipes
ralph-loop
andrelandgraf/fullstackrecipes
Complete setup for automated agent-driven development. Define features as user stories with testable acceptance criteria, then run AI agents in a loop until all stories pass.
ralph-loop-workflow
andrelandgraf/fullstackrecipes
Run a coding agent in an autonomous loop via a /ralph command, gated by a preflight check that every CLI is installed, linked, and authenticated. Use when driving long-running autonomous development from a wide, outcome-focused prompt.
observability-monitoring
andrelandgraf/fullstackrecipes
Complete observability stack with structured logging, error tracking, and web analytics.
stripe-subscriptions
andrelandgraf/fullstackrecipes
Open the skill to read its SKILL.md instructions.
og-image-generation
andrelandgraf/fullstackrecipes
Generate dynamic social preview images using Next.js file conventions and the next/og library. Server-rendered JSX images cached at build time.
shiki-code-blocks
andrelandgraf/fullstackrecipes
Open the skill to read its SKILL.md instructions.
Popular data & databases skills
supabase-postgres-best-practices
supabase/agent-skills
Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pgcron, pgmq), vector/semantic search (pgvector), and restoring dumps (pgrestore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query.
prisma-client-api
prisma/skills
Prisma Client API reference covering model queries, filters, operators, and client methods. Use when writing database queries, using CRUD operations, filtering data, or configuring Prisma Client. Triggers on "prisma query", "findMany", "create", "update", "delete", "$transaction".
prisma-database-setup
prisma/skills
Deprecated compatibility name for prisma-orm-setup. Use only when a user or existing integration explicitly invokes prisma-database-setup; otherwise select prisma-orm-setup.
prisma-cli
prisma/skills
Prisma ORM 7 CLI reference for existing Prisma 7 applications or explicitly selected Prisma 7 workflows. Covers prisma init, generate, migrate, db, dev, studio, and mcp. For setup, connection repair, or Prisma 8, use prisma-orm-setup; not the Prisma Platform CLI.
prisma-postgres
prisma/skills
Deprecated compatibility name for prisma-postgres-setup. Use only when a user or existing integration explicitly invokes prisma-postgres; otherwise select prisma-postgres-setup.
prisma-driver-adapter-implementation
prisma/skills
Required reference for Prisma ORM 7 SQL driver adapter work. Use when implementing or modifying adapters, adding database drivers, or touching SqlDriverAdapter, Transaction, savepoint, result mapping, or DriverAdapterError behavior. Covers current transaction lifecycle, optional savepoint hooks, original database-error preservation, and verification.