Hey, is it possible to use `aggrigate` to sum up a...
# orm-help
k
Hey, is it possible to use
aggrigate
to sum up a field within a relation query. Have a look at the my query below -
const profiles = await prisma.profile.findMany({
include: {
offer: true,
meeting: true,
sale: true
},
orderBy: {
points: "desc"
},
take: 10
})
I want to get the sum of offer, meeting and sale, Individually
1
t
It may not be possible in one prisma query by lack of join tables aggregated, If you want to do that, aggregate from each offer, meeting, sale models by
groupBy
keeping association id and mapping with nodejs code. Or use
$executeRaw
I ordinarily do for performance.
k
Okay, thanks for the advice