Be More Productive with
MongoDB & Prisma

Bring your developer experience to the next level. Prisma makes it easier than ever to work with your MongoDB database and enables you to query data with confidence.

tech

What is Prisma?

Prisma makes working with data easy! It offers a type-safe Node.js & TypeScript ORM, global database caching, connection pooling, and real-time database events.

Query
// Creating a new record
await prisma.user.create({
firstName: “Alice”,
email: “alice@prisma.io”
})
Table
id firstName email
1 Bobby bobby@tables.io
2 Nilufar nilu@email.com
3 Jürgen jums@dums.edu
4 Alice alice@prisma.io

How Prisma and MongoDB fit together

MongoDB is a powerful NoSQL database that allows developers to intuitively work with their data. However, due to its schemaless nature, developers may run into data inconsistencies as they’re evolving their applications.

Prisma is a next-generation ORM/ODM that makes it easier to ensure data consistency by providing an easy-to-read schema and a type-safe database client with auto-completion for all queries.

Read

Reading data in MongoDB with Prisma Client

Prisma Client provides a powerful API for reading data in MongoDB, including filters, pagination, ordering and relational queries for embedded documents and reference-based relations.

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 });
Create
Update
Delete
Schema

Reading data in MongoDB with Prisma Client

Prisma Client provides a powerful API for reading data in MongoDB, including filters, pagination, ordering and relational queries for embedded documents and reference-based relations.

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 });

“We believe that the combination of MongoDB Atlas Serverless and Prisma Accelerate will greatly simplify the process of building and deploying serverless applications in the cloud, especially for workloads that need to scale to high connection counts.”

Kevin Jernigan Kevin Jernigan -
Principal Product Manager of MongoDB

Why Prisma and MongoDB?

Intuitive Data Modeling

The Prisma schema uses an intuitive modeling language that is easy to read and understand for every team member.

High Productivity & Confidence

Prisma has an intuitive querying API with auto-completion so that you can find the right queries directly in your editor.

Ensured Data Consistency

Prisma’s schema-aware database client ensures that you never bring your data in an inconsistent state.

Fantastic DX

Prisma is well-known for its outstanding developer experience and is loved by developers around the world for it.

First-Class Type-Safety

Prisma provides strong type-safety when used with TypeScript, even for relations and partial queries.

Huge Community & Support

Prisma has a huge Discord community, regularly hosts events and provides helpful support via GitHub.

tutorial

Build A Fullstack App with Remix, Prisma & MongoDB

Through this five-part tutorial, you will learn how to build a fullstack application from the ground up using Prisma with MongoDB.The series covers database configuration, data modeling, authentication, CRUD operations, images uploads and deployment to Vercel.

blog

Prisma adds support for MongoDB

Support for MongoDB has been one of the most requested features since the initial release of the Prisma ORM. Using both technologies together makes developers more productive and allows them to ship more ambitious software faster. Our 3.12 release adds stable and production-ready support for MongoDB.

Our MongoDB Resources

Using Prisma with MongoDB

In this guide, you will learn about the concepts behind using Prisma and MongoDB, the commonalities and differences between MongoDB and other database providers, and the process for configuring your application to integrate with MongoDB using Prisma.

MongoDB in the Data Guide

Learn how to use MongoDB to its fullest to take advantage of the performance and features that developers have grown to rely on.

Watch

In this episode of What’s New in Prisma, Matt takes you through a demo of the embedded document support in MongoDB.