studio icon indicating copy to clipboard operation
studio copied to clipboard

Fix Prisma Studio MongoDB Many-to-Many Relations

Open Teekola opened this issue 2 years ago • 4 comments

Problem

It is currently not possible to create records that have Many-to-Many Relations using Prisma Studio and MongoDB. This means that it is not possible in Prisma Data Platform either.

Suggested solution

It should be possible to create records that have Many-to-Many relations in Prisma Studio and Prisma Data Platform regardless of which database is used.

Additional context

For instance, consider the following schema:

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
}

model Order {
  id         String    @id @default(auto()) @map("_id") @db.ObjectId
  products   Product[] @relation(fields: [productIds], references: [id])
  productIds String[]  @db.ObjectId
}

model Product {
  id       String   @id @default(auto()) @map("_id") @db.ObjectId
  orders   Order[]  @relation(fields: [orderIds], references: [id])
  orderIds String[] @db.ObjectId
}

Now when we try to create a product record in Prisma Studio, we get the following errors: Prisma Studio step1 Prisma Studio step2

Teekola avatar Jul 14 '22 08:07 Teekola

Thanks for your feedback! We've added it to our long-term roadmap. In the near future, we're not planning on adding new features to Studio (and Data Browser), but this is on our list now.

petradonka avatar Jul 15 '22 09:07 petradonka

+1 I am also unable to create records with many to many relations in mongodb on prisma version 4.12.0

CarlosBalladares avatar Apr 17 '23 07:04 CarlosBalladares

I have same issue as well. Can't add records while using many-to-many relations MongoDB. Any solution to this?

techwithnaga avatar Dec 04 '23 05:12 techwithnaga

what is the latest news? I think that it still hasn't been fixed, The add record button is disabled and I presumed it is still an issue

Adoo2401 avatar Mar 29 '24 17:03 Adoo2401