Prisma (with MongoDB) sort based on their related field

Hi! How can I retrieve all users from the User model in Prisma (with MongoDB), and sort them based on their total points from the related ShadePoints model? I am currently using Prisma with MongoDB, What is the best way to sort users by the sum of their related ShadePoints.points using Prisma? Is there an example using or an alternative approach? model User { id String @id @default(auto()) @map("_id") @db.ObjectId name String shadePoints ShadePoints[] } model ShadePoints { id String @id @default(auto()) @map("_id") @db.ObjectId points Int userId String @db.ObjectId user User @relation(fields: [userId], references: [id]) }
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server