From d41c5d67f5d1d0ad2b60fbe2a0770ede5fe2fdf5 Mon Sep 17 00:00:00 2001 From: ruheni Date: Wed, 29 Mar 2023 15:25:29 +0200 Subject: [PATCH 1/3] chore: update MongoDB getting started guide --- .../120-mongodb/125-creating-the-prisma-schema.mdx | 14 +++++++++++--- .../120-mongodb/250-querying-the-database.mdx | 1 + .../100-start-from-scratch/120-mongodb/index.mdx | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/125-creating-the-prisma-schema.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/125-creating-the-prisma-schema.mdx index 99822e5167..90c2677738 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/125-creating-the-prisma-schema.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/125-creating-the-prisma-schema.mdx @@ -1,15 +1,15 @@ --- title: 'Creating the Prisma schema' metaTitle: 'Creating the Prisma schema' -metaDescription: 'Manually create the Prisma schema for MongoDB' +metaDescription: 'Update the Prisma schema for MongoDB' langSwitcher: ['typescript', 'node'] dbSwitcher: ['mongodb'] toc: false --- -## Manually create the Prisma schema +## Update the Prisma schema -Open the `prisma/schema.prisma` file and replace the default configurations with the following: +Open the `prisma/schema.prisma` file and replace the default contents with the following: ```prisma file=prisma/schema.prisma datasource db { @@ -28,6 +28,7 @@ model Post { body String author User @relation(fields: [authorId], references: [id]) authorId String @db.ObjectId + comments Comment[] } model User { @@ -38,6 +39,13 @@ model User { posts Post[] } +model Comment { + id String @id @default(auto()) @map("_id") @db.ObjectId + post Post @relation(fields: [postId], references: [id]) + postId String @db.ObjectId + comment String +} + // Address is an embedded document type Address { street String diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/250-querying-the-database.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/250-querying-the-database.mdx index 18069557ed..e51882d0db 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/250-querying-the-database.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/250-querying-the-database.mdx @@ -228,6 +228,7 @@ The output should look similar to this: id: '60cc9b0e001e3bfd00a6eddf', email: 'hello@prisma.com', name: 'Rich', + address: null, posts: [ { id: '60cc9bad005059d6007f45dd', diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/index.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/index.mdx index 9ad6c49c02..2f294186a7 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/index.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/index.mdx @@ -85,7 +85,7 @@ npx prisma Next, set up your Prisma project by creating your [Prisma schema](/concepts/components/prisma-schema) file with the following command: ```terminal copy -npx prisma init +npx prisma init --datasource-provider mongodb ``` This command does two things: From 2b3c321e94cdf039f4e9036d3b83ca7c4a1a47ed Mon Sep 17 00:00:00 2001 From: ruheni Date: Wed, 29 Mar 2023 15:30:08 +0200 Subject: [PATCH 2/3] chore: remove datasource flag --- .../100-start-from-scratch/120-mongodb/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/index.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/index.mdx index 2f294186a7..9ad6c49c02 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/index.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/index.mdx @@ -85,7 +85,7 @@ npx prisma Next, set up your Prisma project by creating your [Prisma schema](/concepts/components/prisma-schema) file with the following command: ```terminal copy -npx prisma init --datasource-provider mongodb +npx prisma init ``` This command does two things: From 878ce7cfe52ef728f292d21f0d24967def6755a1 Mon Sep 17 00:00:00 2001 From: Alex Ruheni <33921841+ruheni@users.noreply.github.com> Date: Wed, 29 Mar 2023 15:48:46 +0100 Subject: [PATCH 3/3] Update 125-creating-the-prisma-schema.mdx --- .../120-mongodb/125-creating-the-prisma-schema.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/125-creating-the-prisma-schema.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/125-creating-the-prisma-schema.mdx index 90c2677738..3f8bafbc50 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/125-creating-the-prisma-schema.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/125-creating-the-prisma-schema.mdx @@ -41,9 +41,9 @@ model User { model Comment { id String @id @default(auto()) @map("_id") @db.ObjectId + comment String post Post @relation(fields: [postId], references: [id]) postId String @db.ObjectId - comment String } // Address is an embedded document