// Creating a new recordawait prisma.user.create({firstName: “Alice”,email: “alice@prisma.io”})
id firstName email1 Bobby bobby@tables.io2 Nilufar nilu@email.com3 Jürgen jums@dums.edu4 Alice alice@prisma.io
MongoDB 是一个强大的 NoSQL 数据库,允许开发者直观地处理他们的数据。然而,由于其 *无模式* 的特性,开发者在迭代应用时可能会遇到数据不一致的问题。
Prisma 是一个下一代 ORM/ODM,它通过提供易于阅读的模式和一个带有所有查询自动补全功能的类型安全数据库客户端,使确保数据一致性变得更容易。
Prisma Client 为读取 MongoDB 中的数据提供了强大的 API,包括过滤、分页、排序以及针对嵌入文档和基于引用的关联进行的关联查询。
1const usersWithProfile = await prisma.user.findMany({2 where: {3 profile: {4 isSet: true,5 },6 },7 select: {8 id: true,9 profile: {10 select: {11 profilePicture: true,12 },13 },14 posts: {15 where: {16 published: true,17 },18 },19 },20 take: 10,21 orderBy: {22 profile: {23 firstName: "asc",24 },25 },26 });
Prisma Client 为读取 MongoDB 中的数据提供了强大的 API,包括过滤、分页、排序以及针对嵌入文档和基于引用的关联进行的关联查询。
1const usersWithProfile = await prisma.user.findMany({2 where: {3 profile: {4 isSet: true,5 },6 },7 select: {8 id: true,9 profile: {10 select: {11 profilePicture: true,12 },13 },14 posts: {15 where: {16 published: true,17 },18 },19 },20 take: 10,21 orderBy: {22 profile: {23 firstName: "asc",24 },25 },26 });
“我们相信,MongoDB Atlas Serverless 和 Prisma Accelerate 的结合将极大地简化在云中构建和部署无服务器应用的过程,特别是对于需要扩展到高连接数的工作负载。”
Prisma 模式使用直观的建模语言,易于所有团队成员阅读和理解。
Prisma 具有直观的查询 API 和自动补全功能,以便你可以在编辑器中直接找到正确的查询。
Prisma 感知模式的数据库客户端确保你的数据永远不会处于不一致的状态。
Prisma 以其出色的开发者体验而闻名,并因此受到全球开发者的喜爱。
当与 TypeScript 一起使用时,Prisma 提供强大的类型安全,甚至对于关联和部分查询也是如此。
Prisma 拥有一个庞大的 Discord 社区,定期举办活动,并通过 GitHub 提供有用的支持。
在本指南中,你将了解使用 Prisma 和 MongoDB 背后的概念,MongoDB 与其他数据库提供商之间的共同点和差异,以及使用 Prisma 配置应用以集成 MongoDB 的过程。
学习如何充分利用 MongoDB,从而利用开发者越来越依赖的性能和特性。
我们提供了多个渠道,你可以在其中与社区成员以及 Prisma 团队进行互动。