model Community { id String @id @default(cui...
# orm-help
p
model Community { id String @id @default(cuid()) commName String? commType String? commAbout String? members User[] manager User @relation(fields: [managerId], references: [id]) managerId String @unique } Hello, I want to create a community schema. Like a group or channel that has many users. And has a user as the community manager. But I got this error error: Error validating model "Community": Ambiguous relation detected. The fields
members
and
manager
in model
Community
both refer to
User
. Please provide different relation names for them by adding `@relation(<name>). How do I go about this? Am new to prisma. I haven't understood the docs fully
✅ 1
l
You are referencing User twice in the same model so you need to specify the relationship with a name:
Copy code
model Community {
  id  String    @id @default(cuid())
  commName String?
  commType String?
  commAbout String?
  members  User[] @relation(name: "CommunityMembers")
  manager   User @relation(name: "CommunityManager",fields: [managerId], references: [id])
  managerId      String @unique
}
and then add the same name in your User model for the relationship to Community
🙌 1
✅ 1
p
Thanks
n
Just for reference: Docs link for Disambiguating relations.