[ad_1]
I am a newbie with Prisma and would like to see how would prisma user do such a call.
I have the following models:
model ChallengeScore {
id Int @id @default(autoincrement())
user User @relation(fields: [username], references: [username])
username String
challenge Challenge @relation(fields: [challengeAddress], references: [address])
challengeAddress String
isGasScore Boolean
isByteScore Boolean
score Int
}
model Challenge {
address String @unique
id Int @id @default(autoincrement())
description String
title String
challengeScores ChallengeScore[]
}
What I want is fetch the challengeScores of a specific user for specific address where isGasScore is true and where score is the lowest. I want to do the same thing for isByteScore is true and score is the lowest.
I also want to fetch for the same specific address the 5 lowest scores (for any users) where isByteScore is true and where is isGasScore is true.
Is it doable in one call? If so what would it look like?
Also what is best practice, should I just fetch all the challengeScores and then filter it out the way I want on the front-end? I am guessing the first option is more costy db wise?
Any advice is appreciated !
Thank you
[ad_2]