Markey Boi
09/21/2021, 12:53 AMRyan
09/21/2021, 6:48 AMEXISTS and custom fields like difference of COUNT , so a raw query would be a better fit in this case.Markey Boi
09/21/2021, 2:35 PMRyan
09/21/2021, 2:38 PMmodel Post {
id Int @id
upvotes Int @default(0)
downvotes Int @default(0)
}Markey Boi
09/21/2021, 2:46 PMconst posts = await this.prisma.post.findMany({
include: {
_count: {
select: {
upvote: true,
downvote: true
}
},
upvote: {
where: {
accountId: accountId
}
},
downvote: {
where: {
accountId: accountId
}
}
}
});Markey Boi
09/21/2021, 2:47 PMRyan
09/21/2021, 2:56 PMRyan
09/21/2021, 3:01 PM