边缘函数
如果你的应用是通过 "边缘函数" 产品部署的,或者是从 serverless 产品部署的,并且具有非标准运行时,则它是边缘部署的应用。此类产品的常见示例包括 Cloudflare Worker 或页面、Vercel Edge 函数或 Edge 中间件 和 Deno 部署。
¥If your application is deployed via an "Edge Function" offering or is deployed from a serverless offering and has a non-standard runtime, it is a edge-deployed app. Common examples for such offerings include Cloudflare Workers or Pages, Vercel Edge Functions or Edge Middleware, and Deno Deploy.
如果 Prisma ORM 的 Rust 引擎二进制文件导致包体积过大、构建速度缓慢或部署问题(例如,在无服务器或边缘环境中),你可以使用 generator
块的以下配置来使用它,而无需使用它们:
¥If Prisma ORM's Rust engine binaries cause large bundle sizes, slow builds, or deployment issues (for example, in serverless or edge environments), you can use it without them using this configuration of your generator
block:
generator client {
provider = "prisma-client-js" // or "prisma-client"
engineType = "client"
}
自 v6.16.0 以来,不带 Rust 二进制文件的 Prisma ORM 一直是 一般可用。
¥Prisma ORM without Rust binaries has been Generally Available since v6.16.0.
请注意,在这种情况下,你需要使用 驱动适配器。
¥Note that you need to use a driver adapter in this case.
使用此架构时:
¥When using this architecture:
-
无需下载或安装 Rust 查询引擎二进制文件。
¥No Rust query engine binary is downloaded or shipped.
-
数据库连接池由你安装的原生 JS 数据库驱动程序(例如,PostgreSQL 的
@prisma/adapter-pg
)维护。¥The database connection pool is maintained by the native JS database driver you install (e.g.,
@prisma/adapter-pg
for PostgreSQL).
此设置可以简化无服务器或边缘运行时中的部署。在 文档在这里 中了解更多信息。
¥This setup can simplify deployments in serverless or edge runtimes. Learn more in the docs here.
好奇我们为什么放弃 Rust 引擎?了解为什么我们在 博客文章 中从 Rust 二进制引擎过渡到全 TypeScript 方法,以实现更快、更轻量的 Prisma ORM。
¥Curious why we moved away from the Rust engine? Take a look at why we transitioned from Rust binary engines to an all-TypeScript approach for a faster, lighter Prisma ORM in this blog post.
在这个部分
¥In this section
概述
你可以将使用 Prisma ORM 的应用部署到边缘。根据你使用的边缘函数提供商和数据库,有不同的注意事项和需要注意的事项。
部署到 Cloudflare
本页面涵盖了使用 Prisma ORM 将应用部署到 Cloudflare Worker 或 Cloudflare 页面 所需了解的所有信息。
部署到 Vercel
本页面涵盖了部署使用 Prisma 客户端与 Vercel 边缘中间件 中的数据库或部署到 Vercel 边缘运行时 的 维塞尔函数 中的数据库进行通信的应用所需了解的所有内容。
部署到 Deno 部署
通过本指南,你可以了解如何构建简单的应用并将其部署到 Deno 部署。应用使用 Prisma ORM 将每个请求的日志保存到 Prisma Postgres 数据库。