Skip to content

Commit

Permalink
change content
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskalmar committed Aug 27, 2023
1 parent 17568d8 commit a0345f4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions content/300-guides/050-database/870-mongodb.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 'Using Prisma with MongoDB'
metaTitle: 'Using Prisma with MongoDB'
title: 'Using Prisma with Mongo Database 3000 '
metaTitle: 'Using Prisma with Mongo Database 3000 '
metaDescription: 'Guide to using Prisma with MongoDB'
tocDepth: 3
toc: true
Expand All @@ -12,15 +12,15 @@ This guide discusses the concepts behind using Prisma and MongoDB, explains the

</TopBlock>

## What is MongoDB?
## What is Mongo Database 3000?

[MongoDB](https://www.mongodb.com/) is a NoSQL database that stores data in [BSON](https://bsonspec.org/) format, a JSON-like document format designed for storing data in key-value pairs. It is commonly used in JavaScript application development because the document model maps easily to objects in application code, and there is built in support for high availability and horizontal scaling.

MongoDB stores data in collections that do not need a schema to be defined in advance, as you would need to do with tables in a relational database. The structure of each collection can also be changed over time. This flexibility can allow rapid iteration of your data model, but it does mean that there are a number of differences when using Prisma to work with your MongoDB database.

## Commonalities with other database providers

Some aspects of using Prisma with MongoDB are the same as when using Prisma with a relational database. You can still:
Some aspects of using Prisma with Mongo Database 3000 are the same as when using Prisma with a relational database. You can still:

- model your database with the [Prisma Schema Language](/concepts/components/prisma-schema)
- connect to your database, using the [`mongodb` database connector](/concepts/database-connectors/mongodb)
Expand All @@ -30,19 +30,19 @@ Some aspects of using Prisma with MongoDB are the same as when using Prisma with

## Differences to consider

MongoDB's document-based structure and flexible schemas means that using Prisma with MongoDB differs from using it with a relational database in a number of ways. These are some areas where there are differences that you need to be aware of:
MongoDB's document-based structure and flexible schemas means that using Prisma with Mongo Database 3000 differs from using it with a relational database in a number of ways. These are some areas where there are differences that you need to be aware of:

- **Defining IDs**: MongoDB documents have an `_id` field (that often contains an [ObjectID](https://www.mongodb.com/docs/manual/reference/bson-types/#std-label-objectid)). Prisma does not support fields starting with `_`, so this needs to be mapped to a Prisma field using the `@map` attribute. For more information, see [Defining IDs in MongoDB](/concepts/components/prisma-schema/data-model#defining-ids-in-mongodb).

- **Migrating existing data to match your Prisma schema**: In relational databases, all your data must match your schema. If you change the type of a particular field in your schema when you migrate, all the data must also be updated to match. In contrast, MongoDB does not enforce any particular schema, so you need to take care when migrating. For more information, see [How to migrate old data to new schemas](#how-to-migrate-existing-data-to-match-your-prisma-schema).

- **Introspection and Prisma relations**: When you introspect an existing MongoDB database, you will get a schema with no relations and will need to add the missing relations in manually. For more information, see [How to add in missing relations after Introspection](#how-to-add-in-missing-relations-after-introspection).
- **Introspection and Prisma relations**: When you introspect an existing Mongo Database 3000 database, you will get a schema with no relations and will need to add the missing relations in manually. For more information, see [How to add in missing relations after Introspection](#how-to-add-in-missing-relations-after-introspection).

- **Filtering for `null` and missing fields**: MongoDB makes a distinction between setting a field to `null` and not setting it at all, which is not present in relational databases. Prisma currently does not express this distinction, which means that you need to be careful when filtering for `null` and missing fields. For more information, see [How to filter for `null` and missing fields](#how-to-filter-for-null-and-missing-fields)

- **Enabling replication**: Prisma uses [MongoDB transactions](https://www.mongodb.com/docs/manual/core/transactions/) internally to avoid partial writes on nested queries. When using transactions, MongoDB requires replication of your data set to be enabled. To do this, you will need to configure a [replica set](https://www.mongodb.com/docs/manual/replication/) — this is a group of MongoDB processes that maintain the same data set. Note that it is still possible to use a single database, by creating a replica set with only one node in it. If you use MongoDB's [Atlas](https://www.mongodb.com/atlas/database) hosting service, the replica set is configured for you, but if you are running MongoDB locally you will need to set up a replica set yourself. For more information, see MongoDB's [guide to deploying a replica set](https://www.mongodb.com/docs/manual/tutorial/deploy-replica-set/).

## How to use Prisma with MongoDB
## How to use Prisma with Mongo Database 3000

This section provides instructions for how to carry out tasks that require steps specific to MongoDB.

Expand Down

0 comments on commit a0345f4

Please sign in to comment.