有没有办法让 MongoDB 在 Vercel Edge Serverless Functions 上工作

Max*_*Max 5 mongodb next.js vercel

在 Vercel Serverless Functions 上使用 API 制作新文档时,我遇到了很长的冷启动时间。为了加快请求速度,我想在 Vercel Edge Functions 上运行 API,但 Edge 运行时不支持 MongoDB 官方 Node 驱动程序。有什么办法可以解决这个限制/我可以使用非官方驱动程序吗?

Ste*_*ion 1

一种方法是将 Prisma ORM 与 MongoDB 结合使用。Vercel 的 Edge 函数不支持大多数 Node.js API(参考:https: //vercel.com/docs/concepts/functions/edge-functions)。

但是,您可以使用 Prisma 数据代理来绕过它,该代理允许您通过 HTTP 与数据库进行交互。(参考: https: //www.prisma.io/blog/database-access-on-the-edge-8F0t1s1BqOJE