Manish
06/02/2021, 5:30 AMconst user = await prisma.user.findFirst({
where: { username: username },
include: {
posts: {
include: {
likedBy:true,
}
},
}
})
I’m getting a user with a specific user name, and I’m also getting the posts for the user. And for each post, I’m getting likedBy (which is a relation).
This works perfectly.
However, instead of getting the array of likedBy, if I want to get the count of liked by, I do the following:
const user = await prisma.user.findFirst({
where: { username: username },
include: {
posts: {
include: {
_count: {
select: {
likedBy:true
}
}
}
},
}
})
This query fails with error: PANIC in query-engine.
Can you help me with it?
Note that I’m able to use _count on likedBy if i’m just getting posts.Ryan
06/02/2021, 7:03 AM_count parameter can only be used on a top level include or select and not nested levels as mentioned in the docs.
I would suggest adding feedback to this issue here so that we can look into this 🙂Manish
06/02/2021, 11:58 AM