I am trying to show a leaderboard which shows the ...
# orm-help
r
I am trying to show a leaderboard which shows the user with the most Solves (or the most points through a Solve) in a list. I am trying to do this via an prisma.solve.groupBy(..) but Im not sure how I can include the relations here (challenge.points and user.name). Any hints? This is my schema:
Copy code
model Challenge {
  id            Int       @default(autoincrement()) @id
  title      String
  text       String
  solution   String
  points     Int

  solves     Solve[]
}

model Solve {
  user   User @relation(fields: [userId], references: [id])
  userId Int

  challenge   Challenge @relation(fields: [challengeId], references: [id])
  challengeId Int

  createdAt DateTime @default(now()) @map(name: "created_at")

  @@id([userId, challengeId])
}