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 } } }
}
}
}
}
});
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 |
个人创作者计费通道上线后直接升级计费
这个技能覆盖了主流数据库操作方法,内容比较全面,但缺少使用说明和示例,实际使用可能不够方便。文档质量尚可,但有些小问题(如乱码)需要修复。如果你需要数据库相关的帮助,可以尝试使用,但建议期待更完善的版本。总体而言是一个基础可用的技能,但还有改进空间。