drizzle-orm-patterns
БесплатноЗапускает вложенные скриптыНе проверенThis skill provides comprehensive Drizzle ORM patterns for PostgreSQL with Vercel Edge Runtime support. Drizzle is Quetrex's chosen ORM because it's…
от aiskillstore★ 509 звёзд на GitHubОб этом скилле
Drizzle ORM Patterns - Complete PostgreSQL Reference
Use when: Working with database operations, schema design, migrations, or queries in Quetrex.
Overview
This skill provides comprehensive Drizzle ORM patterns for PostgreSQL with Vercel Edge Runtime support. Drizzle is Quetrex's chosen ORM because it's edge-first, type-safe, and supports all deployment targets.
Why Drizzle?
- Edge Runtime Compatible: Works with Vercel Edge Functions, Cloudflare Workers
- Type-Safe: Full TypeScript inference without code generation
- Zero Dependencies: No heavy Node.js runtime requirements
- SQL-Like API: Familiar to developers who know SQL
- Lightweight: ~7.4kb minified (vs Prisma's ~300kb)
Skill Structure
This skill is organized into focused modules:
1. queries-complete.md
Complete query patterns: select, insert, update, delete, joins, pagination, filtering, aggregations, subqueries, CTEs.
When to use:
- Building any database query
- Fetching data with filters
- Inserting/updating/deleting records
- Pagination or sorting
- Aggregating data (count, sum, avg)
- Complex joins or subqueries
2. transactions.md
Transaction patterns: isolation levels, rollback, nested transactions, error handling, deadlock prevention.
When to use:
- Multiple operations that must succeed together
- Financial operations (payments, transfers)
- Data consistency requirements
- Race condition prevention
- Complex multi-step workflows
3. relations.md
Relationship patterns: one-to-one, one-to-many, many-to-many, self-referencing, cascading deletes, nested queries.
When to use:
- Defining schema relationships
- Querying related data
- Setting up cascading operations
- Working with hierarchical data
- Optimizing related data fetching
4. migrations.md
Migration patterns: schema evolution, data migrations, zero-downtime deployments, rollback strategies.
When to use:
- Adding/modifying database schema
- Migrating data between schemas
- Deploying schema changes
- Rolling back problematic migrations
- Renaming tables/columns safely
5. edge-runtime.md
Edge deployment patterns: Vercel Edge Functions, Neon serverless, connection pooling, HTTP-based connections.
When to use:
- Deploying to Vercel Edge Runtime
- Using Neon serverless PostgreSQL
- Optimizing edge function performance
- Configuring connection pooling
- Understanding edge limitations
6. performance.md
Performance patterns: indexing, query optimization, N+1 prevention, batch operations, caching.
When to use:
- Slow queries
- High database load
- N+1 query problems
- Large data sets
- Performance optimization needed
7. type-inference.md
TypeScript inference patterns: InferModel, InferSelect, InferInsert, schema types, custom types.
When to use:
- Defining TypeScript types from schema
- Creating API types
- Type-safe query builders
- Custom type mappers
- Ensuring type safety
8. common-mistakes.md
Common pitfalls and fixes: SQL injection risks, N+1 queries, missing indexes, transaction deadlocks, type errors.
When to use:
- Debugging database issues
- Code review
- Learning best practices
- Avoiding common errors
- Security audits
9. validate-queries.py
Python script to validate Drizzle queries for common security and performance issues.
When to use:
- Pre-commit validation
- Security audits
- Performance reviews
- Finding SQL injection risks
- Detecting N+1 patterns
Quick Start
Installation
# Core packages
npm install drizzle-orm @neondatabase/serverless
# Development tools
npm install -D drizzle-kit
Basic Setup
// src/lib/db.ts
import { drizzle } from 'drizzle-orm/neon-http';
import { neon } from '@neondatabase/serverless';
const sql = neon(process.env.DATABASE_URL!);
export const db = drizzle(sql);
Define Schema
// src/lib/schema.ts
import { pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core';
export const users = pgTable('users', {
id: serial('id').primaryKey(),
email: text('email').notNull().unique(),
name: text('name').notNull(),
createdAt: timestamp('created_at').defaultNow().notNull(),
});
Basic Query
// src/services/user-service.ts
import { db } from '@/lib/db';
import { users } from '@/lib/schema';
import { eq } from 'drizzle-orm';
export async function getUserByEmail(email: string) {
return await db.select().from(users).where(eq(users.email, email)).limit(1);
}
Common Patterns
1. Select with Filter
import { db } from '@/lib/db';
import { users } from '@/lib/schema';
import { eq, and, gte } from 'drizzle-orm';
const activeUsers = await db
.select()
.from(users)
.where(
and(
eq(users.status, 'active'),
gte(user
Установить drizzle-orm-patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл drizzle-orm-patterns?
This skill provides comprehensive Drizzle ORM patterns for PostgreSQL with Vercel Edge Runtime support. Drizzle is Quetrex's chosen ORM because it's edge-first, type-safe, and supports all deployme...
Как установить скилл drizzle-orm-patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл drizzle-orm-patterns запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic