Skip to main content

Drizzle

Prisma 和 Drizzle 采用不同的数据库处理方法。Drizzle 吸引的是喜欢编写接近 SQL 查询的开发者,而 Prisma 则旨在支持构建和维护生产应用的团队 - 在这些应用中,清晰度、协作和长期可维护性至关重要。

¥Prisma and Drizzle take different approaches to working with databases. While Drizzle appeals to developers who prefer writing queries close to SQL, Prisma is designed to support teams building and maintaining production applications—where clarity, collaboration, and long-term maintainability matter.

虽然这两个库解决了类似的问题,但它们的工作方式截然不同,并且各有优缺点。选择哪一种取决于你的项目的需求以及对其重要的确切权衡。

¥While both libraries solve similar problems, they work in very different ways and have individual pros and cons. Which one to choose will depend on the needs of your project and the exact tradeoffs that are important for it.

Drizzle 与 Prisma ORM

¥Drizzle vs Prisma ORM

Drizzle 是一个传统的 SQL 查询构建器,可让你使用 JavaScript/TypeScript 函数编写 SQL 查询。它可用于查询数据库或运行迁移。Drizzle 还提供了一个查询 API,它提供了 SQL 的更高级别的抽象,可用于读取嵌套关系。Drizzle 架构在 TypeScript 文件中定义,用于生成 SQL 迁移,然后针对数据库执行。

¥Drizzle is a traditional SQL query builder that lets you compose SQL queries with JavaScript/TypeScript functions. It can be used to query a database or run migrations. Drizzle also offers a Queries API, which offers a higher level abstraction from SQL and can be used to read nested relations. Drizzle schema is defined in TypeScript files, which are used to generate SQL migrations and are then executed against a database.

Prisma ORM 缓解了传统 ORM 的许多问题,例如臃肿的模型实例、业务与存储逻辑混合、缺乏类型安全或导致的不可预测的查询。 通过延迟加载。它使用 Prisma 架构 以声明性方式定义应用模型。然后,Prisma Migrate 允许从 Prisma 模式生成 SQL 迁移并针对数据库执行它们。CRUD 查询由 Prisma Client 提供,这是一个适用于 Node.js 和 TypeScript 的轻量级且完全类型安全的数据库客户端。

¥Prisma ORM mitigates many problems of traditional ORMs, such as bloated model instances, mixing business with storage logic, lack of type-safety or unpredictable queries caused e.g. by lazy loading. It uses the Prisma schema to define application models in a declarative way. Prisma Migrate then allows the generation of SQL migrations from the Prisma schema and executes them against the database. CRUD queries are provided by Prisma Client, a lightweight and entirely type-safe database client for Node.js and TypeScript.

Prisma:专为团队打造

¥Prisma: Built for Teams

Prisma 旨在帮助团队更快地交付,尤其是在并非每个人都是 SQL 专家的情况下。

¥Prisma is designed to help teams ship faster—especially when not everyone is a SQL expert.

  • 无 SQL 瓶颈:使用 Prisma,你无需深厚的 SQL 知识即可高效工作。你的整个团队都可以为后端代码做出贡献,而无需依赖任何一个人编写原始查询或调试数据库逻辑。

    ¥No SQL bottlenecks: With Prisma, you don’t need deep SQL knowledge to be productive. Your entire team can contribute to backend code—without relying on one person to write raw queries or debug database logic.

  • 共享思维模型:Prisma 的模式易于理解且易于推断。它为你的应用数据模型提供了单一、一致的视图。

    ¥Shared mental model: Prisma’s schema is human-readable and easy to reason about. It provides a single, consistent view of your application’s data model.

  • 更轻松的代码审查:模式更改和数据访问模式透明且一致,使审核人员更容易理解和批准后端更改。

    ¥Easier code reviews: Schema changes and data access patterns are transparent and consistent, making it easier for reviewers to understand and approve backend changes.

  • 可预测的工作流程:Prisma 可自动生成迁移、客户端类型输入和查询构建,因此你的团队无需亲自动手。

    ¥Predictable workflows: Prisma automates migration generation, client typing, and query construction—so your team doesn’t have to.

对于了解 SQL 或喜欢学习 SQL 的单个开发者来说,Drizzle 会非常出色。但是,一旦你拥有了团队,Prisma 就会消除阻碍你发展的摩擦和知识风险。

¥Drizzle can be great in the hands of a single developer who knows SQL or prefers learning it. But once you have a team, Prisma removes the friction and knowledge risk that slows you down.

类型安全

¥Type safety

Drizzle 不是完全类型安全的。正如第三方完成的这个 比较研究 中引用的那样,“Drizzle 给人一种类型安全的印象。但是,只有查询结果具有类型信息。你可以使用 Drizzle 编写无效查询。”

¥Drizzle is not fully type safe. As quoted on this comparison study done by a 3rd party, "Drizzle gives the impression of type-safety. However, only the query results have type information. You can write invalid queries with Drizzle."

使用 Prisma,你可以通过生成的类型获得完全的类型安全性。这意味着,在编写代码和与团队成员协作时出错的可能性更小。

¥With Prisma, you get full type safety thanks to the generated types. This means, less potential for errors when writing code and collaborating with team members.

Prisma Schema 作为单一事实来源

¥Prisma Schema as a Single Source of Truth

使用 Prisma,你的数据模型位于单个文件中:schema.prisma.

¥With Prisma, your data model lives in a single file: schema.prisma.

  • 它清晰易懂:无需推断类型或解读 SQL 生成函数 - 你的模式就在那里。

    ¥It’s explicit: No need to infer types or decipher SQL-generating functions—your schema is right there.

  • 它易于阅读:即使非技术团队成员也能理解你的模型和关系。

    ¥It’s readable: Even non-technical teammates can understand your models and relationships.

  • 它为一切提供动力:迁移、TypeScript 类型、自动补齐、ERD 生成等功能均来自你的架构。

    ¥It powers everything: Migrations, TypeScript types, autocompletion, ERD generation, and more all come from your schema.

相比之下,Drizzle 的模式是通过 TypeScript 代码构建的,这使得完整数据模型的可视化变得更加困难,增加了认知负担,并且可能导致整个代码库中模型定义方式不一致。阅读更多 解释了我们为什么看好 PSL(Prisma 模式语言)。

¥In contrast, Drizzle’s schema is built via TypeScript code, which makes it harder to visualize your full data model, increases cognitive load, and can lead to inconsistencies in how models are defined across the codebase. Read more about why we are bullish on PSL (Prisma Schema Language).

想要将你的架构视为 ERD 吗?使用 Prisma,只需一个命令:npx prisma generate && npx prisma-erd-generator

¥Want to see your schema as an ERD? With Prisma, it’s one command: npx prisma generate && npx prisma-erd-generator

API 设计和抽象级别

¥API design & Level of abstraction

Drizzle 和 Prisma ORM 在不同的抽象级别上运行。小雨的理念是 "如果你了解 SQL,你就了解 Drizzle ORM"。它在其 API 中反映了 SQL,而 Prisma Client 提供了更高级别的抽象,该抽象在设计时考虑了应用开发者的常见任务。Prisma ORM 的 API 设计很大程度上依赖于 让正确的事情变得容易 的思想。

¥Drizzle and Prisma ORM operate on different levels of abstraction. Drizzle's philosophy is "If you know SQL, you know Drizzle ORM". It mirrors SQL in its API while Prisma Client provides a higher-level abstraction that was designed with the common tasks of application developers in mind. Prisma ORM's API design heavily leans on the idea of making the right thing easy.

虽然 Prisma Client 在更高的抽象级别上运行,但你可以随时下降到 原始 SQL。然而,充分利用 Prisma ORM 和开发应用不需要 SQL 知识。Prisma ORM 的目标是构建一种专注于开发者体验和生产力的查询语法,让开发者感到熟悉。你可以在这里了解更多相关信息:为什么使用 Prisma

¥While Prisma Client operates on a higher level of abstraction, you are able to drop down to raw SQL at any time. However, full use of Prisma ORM and development of your application does not require SQL knowledge. Prisma ORM's goal is to construct a query syntax focused on developer experience and productivity that feels familiar to developers. You can learn more about this here: Why Prisma.

对于无法在 Prisma Client API 中表达的少数查询,Prisma ORM 还提供了 TypedSQL,它通过直接利用 .sql 文件提供更熟悉和类型安全的体验。你现有的 SQL 工具和工作流程可以与 Prisma Client 一起工作,以处理所需的任何抽象级别。

¥For the few queries that are unable to be expressed in the Prisma Client API, Prisma ORM also offers TypedSQL which provides a more familiar and type-safe experience by directly utilizing .sql files. Your existing SQL tooling and workflow can work alongside Prisma Client to handle any level of abstraction desired.

虽然 Prisma ORM 中可以使用 TypedSQL 提供完全类型的 SQL 查询,但以下部分将介绍一些 Prisma 和 Drizzle API 的不同之处以及在这些情况下 Prisma ORM 的 API 设计原理的示例。

¥While fully typed SQL queries are available in Prisma ORM with TypedSQL, the following sections examine a few examples of how the Prisma and Drizzle APIs differ and what the rationale of Prisma ORM's API design is in these cases.

数据建模

¥Data modeling

Prisma 模型在 Prisma 架构 中定义,而 Drizzle 使用 TypeScript 函数进行表定义。然后导出这些函数并在查询中使用。

¥Prisma models are defined in the Prisma schema, while Drizzle uses TypeScript functions for table definitions. These functions are then exported and used in queries.

Prisma 生成一个轻量级数据库客户端,该客户端公开定制且完全类型安全的 API,以遵循 DataMapper ORM 模式为 Prisma 架构中定义的模型读取和写入数据。

¥Prisma generates a lightweight database client that exposes a tailored and fully type-safe API to read and write data for the models that are defined in the Prisma schema, following the DataMapper ORM pattern.

Prisma ORM 的数据建模 DSL 精益、简单且直观易用。在 VS Code 中对数据进行建模时,你可以进一步利用 Prisma ORM 强大的 VS Code 扩展 功能,例如自动补齐、快速修复、跳转到定义以及其他可提高开发者工作效率的优势。另一方面,Drizzle 对 TypeScript 的使用意味着你可以依靠 TypeScript 的强大功能来获得额外的灵活性(例如,通过重用代码)。

¥Prisma ORM's DSL for data modeling is lean, simple and intuitive to use. When modeling data in VS Code, you can further take advantage of Prisma ORM's powerful VS Code extension with features like autocompletion, quick fixes, jump to definition and other benefits that increase developer productivity. On the other hand, Drizzle's use of TypeScript means that you can lean on the power of TypeScript for additional flexibility (via reused code, for example).

Prisma ORM
model User {
id Int @id @default(autoincrement())
name String?
email String @unique
posts Post[]
}

model Post {
id Int @id @default(autoincrement())
title String
content String?
published Boolean @default(false)
authorId Int?
author User? @relation(fields: [authorId], references: [id])
}
Drizzle
import {
boolean,
integer,
pgTable,
serial,
text,
uniqueIndex,
varchar,
} from 'drizzle-orm/pg-core'

export const users = pgTable('users', {
id: serial('id').primaryKey(),
name: varchar('name', { length: 256 }),
email: varchar('email', { length: 256 }).unique(),
})

export const posts = pgTable('posts', {
id: serial('id').primaryKey(),
title: varchar('title', { length: 256 }).notNull(),
content: text('content'),
published: boolean('published'),
authorId: integer('author_id').references(() => users.id),
})

迁移

¥Migrations

Drizzle 和 Prisma ORM 之间的迁移工作类似。这两个工具都遵循根据提供的模型定义生成 SQL 文件的方法,并提供 CLI 来针对数据库执行它们。可以在执行迁移之前修改 SQL 文件,以便可以使用任一迁移系统执行任何自定义数据库操作。

¥Migrations work similarly between Drizzle and Prisma ORM. Both tools follow the approach of generating SQL files based on the provided model definitions and provide a CLI to execute them against the database. The SQL files can be modified before the migrations are executed so that any custom database operation can be performed with either migration system.

查询

¥Querying

在 Drizzle 和 Prisma ORM 中构建普通查询是很自然的。使用 Drizzle 的查询 API,这两种方法非常相似:

¥Plain queries are natural to construct in both Drizzle and Prisma ORM. Using Drizzle's Queries API, the two approaches are very similar:

Prisma ORM
// find all users
const allUsers = await prisma.user.findMany()

// find a single user
const user = await prisma.user.findFirst({
where: { id: 27 },
})

// find a unique user
const user = await prisma.user.findUnique({
where: { email: 'nilu@prisma.io' },
})
Drizzle
import { eq } from 'drizzle-orm'

// find all users
const allUsers = await db.query.users.findMany()

// find a single user
const user = await db.query.users.findFirst({
where: eq(users.id, 1),
})

// find a unique post
const user = await db.query.users.findFirst({
where: eq(users.email, 'nilu@prisma.io'),
})

执行突变、createupdatedelete 时,Drizzle 查询 API 不可用。在这些情况下,你将需要使用 Drizzle 的类似 SQL 的 API:

¥When performing a mutation, a create, update, or delete, the Drizzle Queries API is not available. In these cases, you will need to use Drizzle's SQL-like APIs:

Prisma ORM
// create a user
const user = await prisma.user.create({
data: {
name: 'Nilu',
email: 'nilu@prisma.io',
},
})

// update a user
const user = await prisma.user.update({
where: { email: 'nilu@prisma.io' },
data: { name: 'Another Nilu' },
})

// delete a user
const deletedUser = await prisma.user.delete({
where: { email: 'nilu@prisma.io' },
})
Drizzle
// create a user
const user = await db.insert(users).values({
name: 'Nilu',
email: 'nilu@prisma.io',
})

// update a user
const user = await db
.update(users)
.set({ name: 'Another Nilu' })
.where(eq(users.email, 'nilu@prisma.io'))
.returning()

// delete a user
const deletedUser = await db
.delete(users)
.where(eq(users.email, 'nilu@prisma.io'))
.returning()

关系

¥Relations

在 SQL 中,处理通过外键连接的记录可能会变得非常复杂。Prisma ORM 的 虚拟关系场 概念为应用开发者提供了一种直观、便捷的方式来处理相关数据。Prisma ORM 方法的一些优点是:

¥Working with records that are connected via foreign keys can become very complex in SQL. Prisma ORM's concept of virtual relation field enables an intuitive and convenient way for application developers to work with related data. Some benefits of Prisma ORM's approach are:

  • 通过 Fluent API 遍历关系 (docs)

    ¥traversing relationships via the fluent API (docs)

  • 允许更新/创建连接记录的嵌套写入 (docs)

    ¥nested writes that enable updating/creating connected records (docs)

  • 对相关记录应用过滤器 (docs)

    ¥applying filters on related records (docs)

  • 轻松且类型安全地查询嵌套数据,无需担心底层 SQL (docs)

    ¥easy and type-safe querying of nested data without worrying about underlying SQL (docs)

  • 基于模型及其关系创建嵌套 TypeScript 类型 (docs)

    ¥creating nested TypeScript typings based on models and their relations (docs)

  • 通过关系字段对数据模型中的关系进行直观建模 (docs)

    ¥intuitive modeling of relations in the data model via relation fields (docs)

  • 关系表的隐式处理(有时也称为 JOIN、链接、数据透视表或联结表)(docs)

    ¥implicit handling of relation tables (also sometimes called JOIN, link, pivot or junction tables) (docs)

Prisma ORM
const posts = await prisma.post.findMany({
include: {
author: true,
},
})
Drizzle
const posts = await db.query.posts.findMany({
with: {
author: true,
},
})

过滤

¥Filtering

Drizzle 公开了给定 SQL 方言的底层过滤器和条件运算符。另一方面,Prisma ORM 提供了更加直观易用的 通用运算符集

¥Drizzle exposes the underlying filter and conditional operators for a given SQL dialect. Prisma ORM on the other hand, provides a more generic set of operators that are intuitive to use.

Drizzle 和 Prisma ORM 的过滤 API 有何不同的一个很好的例子是查看 string 过滤器。虽然 Drizzle 提供了 likeilike 的过滤器,但 Prisma ORM 提供了开发者可以使用的更具体的运算符,例如:containsstartsWithendsWith

¥A good example of how the filtering APIs of both Drizzle and Prisma ORM differ is by looking at string filters. While Drizzle provides filters for like and ilike, Prisma ORM provides more specific operators that developers can use, e.g.: contains, startsWith and endsWith.

Prisma ORM
// case sensitive filter
const posts = await prisma.post.findMany({
where: {
title: 'Hello World',
},
})

// case insensitive filter
const posts = await prisma.post.findMany({
where: {
title: 'Hello World',
mode: 'insensitive',
},
})
Drizzle
// case sensitive filter
const posts = await db
.select()
.from(posts)
.where(like(posts.title, 'Hello World'))

// case insensitive filter
const posts = await db
.select()
.from(posts)
.where(ilike(posts.title, 'Hello World'))
Prisma ORM
const posts = await prisma.post.findMany({
where: {
title: {
contains: 'Hello World',
},
},
})
Drizzle
const posts = await db
.select()
.from(posts)
.where(ilike(posts.title, '%Hello World%'))
Prisma ORM
const posts = await prisma.post.findMany({
where: {
title: {
startsWith: 'Hello World',
},
},
})
Drizzle
const posts = await db
.select()
.from(posts)
.where(ilike(posts.title, 'Hello World%'))
Prisma ORM
const posts = await prisma.post.findMany({
where: {
title: {
endsWith: 'Hello World',
},
},
})
Drizzle
const posts = await db
.select()
.from(posts)
.where(ilike(posts.title, '%Hello World'))

可观察性

¥Observability

Drizzle 和 Prisma ORM 都能够记录查询和生成的底层 SQL。

¥Both Drizzle and Prisma ORM have the ability to log queries and the underlying SQL generated.

Prisma ORM 在客户端中内置了其他功能,可帮助团队更好地了解其数据使用情况。指标tracing 是两个可以随时启用的功能,并为你提供每个查询的信息。此信息可以与外部工具集成,以便你可以跟踪一段时间内的性能。

¥Prisma ORM has additional features built into the client that help teams get a better understanding of their data usage. Metrics and tracing are two features that can be enabled at any time and give you per query information. This information can be integrated with external tools so that you can track performance over time.

附加产品

¥Additional products

Drizzle 和 Prisma 都提供产品以及 ORM。Prisma Studio 的发布允许用户通过 GUI 与数据库进行交互,并且还允许在团队内使用有限的自托管。Drizzle Studio 的发布是为了完成相同的任务。

¥Both Drizzle and Prisma offer products alongside an ORM. Prisma Studio was released to allow users to interact with their database via a GUI and also allows for limited self-hosting for use within a team. Drizzle Studio was released to accomplish the same tasks.

除了 Prisma Studio 之外,Prisma 还通过 Prisma 数据平台提供商业产品:

¥In addition to Prisma Studio, Prisma offers commercial products via the Prisma Data Platform:

  • Prisma 加速:与 Prisma ORM 集成的连接池和全局缓存。用户可以立即利用连接池,并可以在单个查询级别控制缓存。

    ¥Prisma Accelerate: A connection pooler and global cache that integrates with Prisma ORM. Users can take advantage of connection pooling immediately and can control caching at an individual query level.

  • Prisma 优化:查询分析工具可提供深入洞察、可操作建议,并允许你与 Prisma AI 交互以获得进一步洞察并优化数据库查询。

    ¥Prisma Optimize: A query analytics tool that provides deep insights, actionable recommendations, and allows you to interact with Prisma AI for further insights and optimizing your database queries.

这些产品与 Prisma ORM 携手合作,提供全面的数据工具,通过遵循 数据 DX 原则轻松构建数据驱动的应用。

¥These products work hand-in-hand with Prisma ORM to offer comprehensive data tooling, making building data-driven applications easy by following Data DX principles.

更安全的更改和更少的 Bug

¥Safer Changes and Fewer Bugs

Prisma 最大限度地降低了使用数据库时人为错误的风险。

¥Prisma minimizes the risk of human error when working with your database.

  • 重命名字段?Prisma 会更新模式、数据库和生成的客户端。你将自动保持同步。

    ¥Renaming a field? Prisma updates the schema, the database, and the generated client. You stay in sync automatically.

  • 要更改关系吗?Prisma 生成安全的迁移并通过完全类型安全来确保正确性。

    ¥Changing a relationship? Prisma generates a safe migration and enforces correctness via full type safety.

团队选择 Prisma 是因为它能够确保正确性,并帮助你快速行动而不会造成任何破坏。

¥Teams choose Prisma because it enforces correctness and helps you move fast without breaking things.

包含电池的生态系统

¥Batteries-Included Ecosystem

Drizzle 和 Prisma ORM 都有用户想要做一些库不直接支持的事情的情况。Drizzle 依靠 SQL 的表达能力来避免这些情况,而 Prisma ORM 具有 Prisma 客户端扩展 功能,允许任何用户向其 Prisma Client 实例添加其他行为。这些扩展也是可共享的,这意味着团队可以开发它们以供跨项目使用,甚至供其他团队使用。

¥Both Drizzle and Prisma ORM have cases where users want to do something not directly supported by the library. Drizzle relies on the expressiveness of SQL to avoid these cases, while Prisma ORM has Prisma Client extensions to allow any user to add additional behaviors to their instance of Prisma Client. These extensions are also shareable, meaning teams can develop them for use across their projects or even for use by other teams.

虽然 Drizzle 是一个相对较新的产品,但 Prisma ORM 是 2021 年发布,并且在 JavaScript/TypeScript 字段已经很成熟。它的价值已被证明,许多公司都信任 生产中的 Prisma ORM

¥While Drizzle is a relatively new product, Prisma ORM was released in 2021 and is well established in the JavaScript/TypeScript space. It has proven value and many companies trust Prisma ORM in production.

Prisma ORM 还被作为许多元框架和开发平台(如 扩增WaspRedwoodJSKeystoneJSRemixt3 堆栈)中的数据层工具选择。

¥Prisma ORM is also included as the data layer tool of choice in many meta-frameworks and development platforms like Amplication, Wasp, RedwoodJS, KeystoneJS, Remix and the t3 stack.

由于其成熟度,Prisma 社区开发了 大量有用的工具,可帮助完成各种 Prisma 工作流程。以下是一些亮点:

¥Thanks to its maturity, Prisma's community has developed a plethora of useful tools that helps with various Prisma workflows. Here are a few highlights:

Prisma 不仅仅是一个 ORM,它是一个完整的类型安全数据工具包:

¥Prisma isn’t just an ORM—it’s a complete type-safe data toolkit:

  • Prisma Schema → 迁移、​​类型和文档

    ¥Prisma Schema → migrations, types, and documentation

  • Prisma 客户端 → 自动补齐、完全类型安全的查询

    ¥Prisma Client → auto-completed, fully type-safe queries

  • Prisma Studio → 用于检查和编辑数据的 GUI

    ¥Prisma Studio → a GUI to inspect and edit data

  • 原生集成 → PlanetScale、Vercel、Cloudflare D1、Neon 等

    ¥Native integrations → PlanetScale, Vercel, Cloudflare D1, Neon, and more

数据库支持

¥Database support

Drizzle 和 Prisma ORM 都支持多种不同类型的数据库。Drizzle 通过 Drizzle 创建的驱动程序实现来实现此支持,该驱动程序实现与现有的第三方数据库驱动程序集成。

¥Both Drizzle and Prisma ORM support multiple and different kinds of databases. Drizzle achieves this support through driver implementations created by Drizzle, which integrate with existing third-party database drivers.

Prisma ORM 已开始添加对 第三方数据库驱动程序 的支持,但主要使用 内置驱动程序 与底层数据库进行通信。Prisma 还默认连接到 TLS,这提高了安全性。

¥Prisma ORM has begun adding support for third-party database drivers, but primarily uses built-in drivers to communicate with an underlying database. Prisma also defaults connections to TLS, which improves security.

此外,Prisma ORM 支持 CockroachDB、Microsoft SQL Server 和 MongoDB,而 Drizzle 目前尚不支持。Prisma ORM 还提供了 关系模式,允许 Prisma ORM 为那些不支持它的数据库引擎模拟外键约束。Drizzle 目前通过 HTTP 代理支持 Cloudflare D1、bun:sqlite 和 SQLite,而 Prisma ORM 目前不支持。

¥Additionally, Prisma ORM supports CockroachDB, Microsoft SQL Server, and MongoDB, which Drizzle does not currently support. Prisma ORM also offers the relation mode that allows Prisma ORM to emulate foreign key constraints for those database engines that do not support it. Drizzle currently supports Cloudflare D1, bun:sqlite, and SQLite via HTTP Proxy, which Prisma ORM currently does not.

基准

¥Benchmarks

我们了解性能是选择 ORM 时的关键考虑因素。要比较各种 ORM 的性能,你可以使用 Vercel 托管的开源 数据库延迟基准测试工具。此工具允许你评估不同工作负载和配置下各种 ORM 的延迟和吞吐量。通过针对你正在考虑的数据库或数据库提供商运行基准测试,你可以清楚地了解它们的相对性能特性,以帮助做出明智的决定。

¥We understand that performance is a key consideration when selecting an ORM. To compare performance of various ORMs, you can use the open-source database latency benchmark tool hosted by Vercel. This tool allows you to evaluate the latency and throughput of various ORMs under different workloads and configurations. By running the benchmarks against the databases or database providers you are considering, you can get a clear picture of their relative performance characteristics to help make an informed decision.

或者,你也可以查看我们构建的 基准测试工具 上的发现,该发现比较了流行的 TypeScript ORM,包括 Drizzle。此基准测试是开源的,旨在公平比较 Node.js 和 TypeScript 生态系统中数据库提供商和 ORM 库的数据库查询延迟。

¥Alternatively, you can also review findings on the benchmark tool that we have built that compares popular TypeScript ORMs, including Drizzle. This benchmark is open source and aims to be a fair comparison of database query latencies across database providers and ORM libraries in the Node.js and TypeScript ecosystem.

结论

¥Conclusion

是的,我们有偏见,但这也是我们从用户和客户那里听到的:

¥Yes, we are biased, but this is also what we have heard from our users and customers:

  • “我们从 Drizzle 切换到 Prisma 是因为模式漂移让我们很头疼。”Prisma 运行正常。

    ¥"We switched from Drizzle to Prisma because schema drift was killing us. Prisma just works."

  • “得益于 Prisma 的架构,我在 2 小时内就让一名初级开发者入职了。”使用 Drizzle,这可能需要几天时间。

    ¥"I onboarded a junior dev in 2 hours thanks to Prisma’s schema. With Drizzle, it would’ve taken days."

  • “我相信 Prisma 能够保证我们数据库的正常运行。”我们团队中没有人需要成为 Postgres 专家。

    ¥"I trust Prisma to keep our database sane. No one on our team needs to be a Postgres expert."

  • "Prisma 团队的更新和新功能速度非常出色。"

    ¥"The pace of updates and new features from the Prisma team has been nothing short of outstanding."

Drizzle ORM 和 Prisma ORM 都是数据访问和迁移的工具。Drizzle 专注于成为类似 SQL 语法的薄封装器,而 Prisma 则专注于方便且富有表现力的 API。其他重要区别包括 Prisma ORM 对 MSSQL 和 MongoDB 的支持、通过 Prisma 客户端扩展 支持附加功能、附加云就绪产品以及强大的生态系统。

¥Both Drizzle ORM and Prisma ORM are tools for data access and migrations. Drizzle is focused on being a thin wrapper around a SQL-like syntax while Prisma is focused on a convenient and expressive API. Other important differences include Prisma ORM's support of MSSQL and MongoDB, support for additional features via Prisma Client extensions, additional cloud-ready products, and a robust ecosystem.

另一方面,对于由具有不同水平数据库经验的开发者(前端、后端和全栈)组成的团队,Prisma ORM 提供了一种全面且易于学习的数据方法 访问和管理数据库模式。

¥On the other hand, for teams that are a mix of developers (front-end, back-end, and full-stack) that have varying levels of experience with databases, Prisma ORM offers a comprehensive and easy-to-learn approach for data access and managing database schemas.


Stay connected with Prisma

Continue your Prisma journey by connecting with our active community. Stay informed, get involved, and collaborate with other developers:

We genuinely value your involvement and look forward to having you as part of our community!