Hi guys. I'm trying to use folowing prisma schema ...
# orm-help
r
Hi guys. I'm trying to use folowing prisma schema
Copy code
enum Gender {
  MALE
  FEMALE
}

type User {
  id: Int! @id
  createdAt: DateTime! @createdAt
  updatedAt: DateTime! @updatedAt
  firstName: String!
  lastName: String!
  gender: Gender!
  birthday: DateTime!
  email: String! @unique
  password: String!
  phone: String @unique
  avatar: Picture
  usersToClubs: [UserToClub!]
}

type Club {
  id: Int! @id
  createdAt: DateTime! @createdAt
  updatedAt: DateTime! @updatedAt
  name: String! @unique
  description: String
  location: Location
  avatar: Picture
  usersToClubs: [UserToClub!]
}

enum ClubRole {
  MEMBER
  MANAGER
}

type UserToClub @relationTable {
  user: User!
  club: Club!
  role: ClubRole!
}
but get an error
java.util.NoSuchElementException: None.get at scala.None$.get(Option.scala:349)
when
prisma deploy
If change
type UserToClub
to
Copy code
type UserToClub {
  id: Int! @id
  user: User!
  club: Club!
  role: ClubRole!
}
everything is works, but I don't need
id
field in this table
d
Looks like Prisma is asking for an ID field to uniquely identify each row in
UserToClub
table. Because there may be duplicates there, if you insert same (User + Club + Role) more than once.
I am not sure if Prisma allows for Composite key where you can make (user , club) fields as a composite key, that way uniqueness could be guaranteed., This is how things work in SQL databases like SQL Server.
r
Unfortunately, multiple ID fields (compound indexes) are not supported
d
yup, so ID with @id is the way to go for now 😞
r
But I think the problem is
@realtionTable
because
Copy code
type UserToClub @relationTable {
  id: Int! @id
  user: User!
  club: Club!
  role: ClubRole!
}
also throws an error