July 14, 2021

Prisma 2.27 Adds Preview Support for MongoDB

Today we are excited to expand the range of supported databases with preview support of MongoDB. Try it out and let us know what you think!

Contents

TL;DR

  • Prisma release 2.27.0 adds Preview support for MongoDB.
  • Prisma introduces a schema to MongoDB from which Prisma Client is generated, giving you the power of type safety in your queries.
  • Check out the Start from scratch guide in the docs.
  • This is a preview release, so there may be bugs and breaking changes. Try it out and share your feedback

Watch the getting started video: MongoDB with Prisma

Adding MongoDB support to Prisma

MongoDB has been our most requested feature since the release of Prisma 2. Today we're thrilled to announce Preview support for MongoDB in Prisma! 🎉

Earlier this year, we released an Early Access of the MongoDB connector to Prisma Client. Since then, hundreds of engineers signed up for the Early Access program and provided us with helpful feedback.

This release marks a significant milestone in bringing the benefits of Prisma to more developers by adding support for MongoDB.

MongoDB support has passed rigorous testing internally and by the Early Access participants and is now ready for broader testing by the community. However, as a Preview feature, it is not production-ready. To read more about what preview means, check out the maturity levels in the Prisma docs.

Thus, we're inviting the MongoDB community to try it out and give us feedback so we can bring MongoDB support to general availability. 🚀

Making MongoDB type safe with Prisma

Unlike the already supported SQL databases in Prisma, MongoDB is a NoSQL database that makes different assumptions about how to model your data and how you query it.

MongoDB's collections, by default, do not require their documents to have the same schema. While this is one of the benefits of MongoDB, it comes at a cost – as a developer, you have the burden of ensuring the consistency and integrity of your data.

For example, documents in a single collection do not need to have the same set of fields and can have different types for the same field. As your application and data model evolve and you add new fields, it is up to you to manage the complexity of all possible variants of a document in the application layer.

Prisma addresses the challenges of a dynamic schema by allowing you to define and enforce a schema.

You define your data model using Prisma Schema – Prisma's declarative data modeling language.

After defining your Prisma schema, you auto-generate the TypeScript Prisma Client and use it in your application to interact with the database with type safety for all queries. Prisma Client leverages TypeScript's type system to map your Prisma schema models to types, so for every query you write, the exact return type is inferred.

Getting started

This release allows you to use Prisma Client in new MongoDB projects.

To get started with MongoDB, check out the Start from scratch guide in the docs.

If you prefer a guided video, check out the MongoDB with Prisma video.

You can also dig into our ready-to-run example in the prisma-examples repo which includes instructions on how to start a MongoDB server locally and some example scripts to demonstrate Prisma Client queries.

Limitations

Support for MongoDB comes with some limitations that are detailed in this section.

Try Prisma with MongoDB and share your feedback

We built this for you and are eager to hear your feedback!

🐜 Tried it out and found that it's missing something or stumbled upon a bug? Please file an issue so we can look into it.

💡 Are you interested in learning more about MongoDB? Check out the MongoDB section of Prisma's Data Guide.

🌍 We also invite you to join our Slack where you can discuss all things Prisma, share feedback in the #mongodb channel, and get help from the community.

🎥 Watch the Making MongoDB Type Safe with Prisma talk at MongoDB.live on July 14th 19:45 CEST.

💌 Get your free Prisma & MongoDB stickers.

📫 Sign up for the MongoDB mini-newsletter to get the latest updates on MongoDB support in Prisma.

🏗 We are excited to share the preview version of MongoDB support in Prisma finally and can't wait to see what you all build with it.


Get started with Prisma and MongoDB

Join the discussion

Follow @prisma on Twitter

Don’t miss the next post!

Sign up for the Prisma newsletter