Hi, I have this query: ```const user = await pri...
# orm-help
m
Hi, I have this query:
Copy code
const 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:
Copy code
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.
r
@Manish 👋 Currently the
_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 🙂
m
Ok, thank you!
🙌 1