How would you go about modeling this in a Schema? ...
# prisma-client
w
How would you go about modeling this in a Schema?
Copy code
model Dish {
...
}

model Plan {
  ...
  monday Dish[]
  tuesday Dish[]
  wednesday Dish[]
  thursday Dish[]
  ...
}
n
Hey Will 👋 You would need to disambiguate relations between Dish and Plan models. This is required when there are multiple relations between the same two models. You could model it like this:
Copy code
model Dish {
  id              Int   @id @default(autoincrement())
  planMonday      Plan? @relation(name: "monday", fields: [mondayPlanId], references: [id])
  planTuesday     Plan? @relation(name: "tuesday", fields: [tuesdayPlanId], references: [id])
  planWednesday   Plan? @relation(name: "wednesday", fields: [wednesdayPlanId], references: [id])
  planThursday    Plan? @relation(name: "thursday", fields: [thursdayPlanId], references: [id])
  mondayPlanId    Int?
  tuesdayPlanId   Int?
  wednesdayPlanId Int?
  thursdayPlanId  Int?
}

model Plan {
  id        Int    @id @default(autoincrement())
  monday    Dish[] @relation(name: "monday")
  tuesday   Dish[] @relation(name: "tuesday")
  wednesday Dish[] @relation(name: "wednesday")
  thursday  Dish[] @relation(name: "thursday")
}
w
Thank you!
👍 1