name: database-orm-master-en slug: database-orm-master-en version: 1.0.0 displayName: "Database ORM Master" description: "Full-stack database operations expert: complete Prisma ORM guide (schema design/query building/relation mapping/migration management/performance optimization) + Drizzle ORM comparison + raw SQL fallback. Covers advanced CRUD patterns, join queries, aggregation, pagination, sorting, transactions, connection pooling, index optimization. One skill for the entire database lifecycle." tags: ["database", "orm", "prisma", "drizzle", "sql", "backend", "fullstack"] category: developer author: leilei homepage: ""
database operations, Prisma query, ORM design, database migration, join queries, database performance, Drizzle, SQL optimization, create table, CRUD, database connection pool, index optimization, transaction handling
Complete knowledge base and practical guide for mainstream Node.js/TypeScript database solutions.
| ORM/Tool | Version Range | Best For |
|---|---|---|
| Prisma | 4.x - 6.x | Full-featured ORM, type-safe first choice |
| Drizzle ORM | 0.x - 0.30+ | Lightweight, SQL-like experience, TypeScript-native |
| Raw SQL | General | Complex queries / performance-critical fallback |
Input: Business requirements (natural language OK)
Output: Complete Prisma Schema + Drizzle equivalent + migration SQL
Input: Natural language query need
Output: Precise Prisma Client / Drizzle code + equivalent SQL
Input: Slow query code or logs
Output: Bottleneck identification + optimization plan + improved code
Input: Current schema + change requirements
Output: Incremental migration commands + impact assessment + rollback plan
// Users with recent orders (with product details), sorted by order amount desc const usersWithRecentOrders = await prisma.user.findMany({ where: { status: 'active' }, include: { orders: { take: 5, orderBy: { totalAmount: 'desc' }, include: { items: { include: { product: { select: { name: true, price: true } } } } } } } });7w4.net小蔥技能站,你的AI助手技能庫。
import { count, sum, sql } from 'drizzle-orm';
const salesReport = await db.select({
productId: orders.productId,
productName: products.name,
totalSold: count(orders.id),
revenue: sum(orders.totalAmount),
})
.from(orders)
.innerJoin(products, eq(orders.productId, products.id))
.where(gte(orders.createdAt, new Date('2024-01-01')))
.groupBy(orders.productId)
.orderBy(desc(sum(orders.totalAmount)))
.limit(20);
| Pitfall | Symptom | Fix |
|---|---|---|
| N+1 Queries | Many repeated SQL | Use include/select for eager loading |
| Deep Include Explosion | Very slow / OOM | Limit nesting depth, use select for needed fields only |
| Migration Conflicts | Team collaboration conflicts | Use prisma migrate resolve |
| Connection Pool Exhaustion | Timeouts / connection refused | Adjust connection_limit, check for leaks |
| Time Precision Loss | DateTime loses ms/timezone after storage | Use DateTime(tz) or store Unix timestamps |
| Soft Delete Leakage | Deleted data still showing | Add deletedAt field + default filter everywhere |
個人創作者計費通道上線後直接升級計費
這個技能覆蓋了主流資料庫操作方法,內容比較全面,但缺少使用說明和示例,實際使用可能不夠方便。文件質量尚可,但有些小問題(如亂碼)需要修復。如果你需要資料庫相關的幫助,可以嘗試使用,但建議期待更完善的版本。總體而言是一個基礎可用的技能,但還有改進空間。