:warning: Yo boys and girls: Please help me, how d...
# orm-help
r
⚠️ Yo boys and girls: Please help me, how do i fix this. I want a course to have the possibility to have 2 different topics attached (main and sub). Removed all irrelevant properties from the example. I am never fetching the topic + courses, always courses by a topicId but i can’t remove the relation from Topic apparantly.
Copy code
model Course {
  topic           Topic           @relation("Topic", fields: [topicId], references: [id])
  topicId         String          @db.ObjectId
  subTopic        Topic           @relation("SubTopic", fields: [subTopicId], references: [id])
  subTopicId      String          @db.ObjectId
}

model Topic {
  courses.        Course[] ????
}
n
Hey Rene 👋, Can you have a look at this schema and see if it fixes your problem?
Copy code
model Course {
  id         String @id
  topic      Topic  @relation("Topic", fields: [topicId], references: [id])
  topicId    String
  subTopic   Topic  @relation("SubTopic", fields: [subTopicId], references: [id])
  subTopicId String
}

model Topic {
  id             String   @id
  name           String
  CourseTopic    Course[] @relation("Topic")
  CourseSubTopic Course[] @relation("SubTopic")
}
Please let me know in case you face any issues. Here is the guide for implementing relations in case you want to have a look.
r
Seems to work!! Thanks
👍 1