drizzle
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDrizzle ORM
Drizzle ORM
Drizzle is the lightweight challenger to Prisma. v0.30+ (2025) focuses on SQL-like syntax, zero dependencies at runtime, and extreme cold-start performance.
Drizzle是Prisma的轻量级替代方案。2025年发布的v0.30+版本主打类SQL语法、运行时零依赖以及极致的冷启动性能。
When to Use
使用场景
- Serverless: Zero runtime overhead makes it perfect for Lambdas.
- SQL Lovers: You prefer over object APIs.
db.select().from(users) - Performance: Faster query building than Prisma.
- 无服务器架构:零运行时开销使其非常适合Lambda。
- SQL爱好者:相比对象式API,你更倾向于使用这类写法。
db.select().from(users) - 性能优先:查询构建速度比Prisma更快。
Core Concepts
核心概念
Schema Definition
Schema定义
Define tables in TS. .
export const users = pgTable('users', { ... })用TypeScript定义表结构。。
export const users = pgTable('users', { ... })Query Builder
查询构建器
Composable, type-safe SQL builder.
可组合、类型安全的SQL构建器。
Relational API
关联API
db.query.users.findMany({ with: { posts: true } })db.query.users.findMany({ with: { posts: true } })Best Practices (2025)
2025年最佳实践
Do:
- Use : For migration management.
drizzle-kit - Use : Explicit execution model.
run - Use Driver Specifics: Drizzle embraces database-specific features (JSONB, Arrays).
Don't:
- Don't over-abstract: Drizzle shines when you stay close to SQL.
推荐做法:
- 使用:用于迁移管理。
drizzle-kit - 使用:显式执行模型。
run - 利用数据库专属特性:Drizzle支持数据库专属功能(JSONB、数组)。
不推荐做法:
- 不要过度抽象:贴近SQL使用才能发挥Drizzle的优势。