You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Preview feature feedback: Find a relation's count (selectRelationCount ) #6312
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:
Opened #7688 to track this issue, but the _count field doesn't seem to be supported by Prisma.validator and Prisma.XYZGetPayload for partial / related types.
// works fineconstuser=Prisma.validator<Prisma.UserArgs>()({select: {id: true,name: true},});exporttypeUser=Prisma.UserGetPayload<typeofuser>;// TS2322: Type 'boolean' is not assignable to type 'never'.constuserWithCount=Prisma.validator<Prisma.UserArgs>()({select: {id: true,name: true,_count: {select: {posts: true}},},});
Activity
janpio commentedon May 22, 2021
There is one bug at #6543 that was reported multiple times now.
41y08h commentedon May 22, 2021
Nested relation count is the feature that is not working and produces this error.
Hoping to see prisma resolve it fast.
Thanks.
codasana commentedon Jun 2, 2021
Hi,
I have this query:
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:
This query fails with error: PANIC in query-engine.
Looks like: Currently the _count parameter can only be used on a top level include or select and not nested levels.
Can this be supported, please.
SamuelMS commentedon Jun 15, 2021
Opened #7688 to track this issue, but the
_countfield doesn't seem to be supported byPrisma.validatorandPrisma.XYZGetPayloadfor partial / related types.zfanta commentedon Aug 13, 2021
Hi,
I hope the fields of
SomeCountOutputTypeSelectsupport not only boolean type.I have this schema.
And I have to count the valid reports of post. So I use this code that manually calls count function for every post.
If the fields of
SomeCountOutputTypeSelectareboolean|SomeWhereInput, I can use this code.andrelandgraf commentedon Aug 28, 2021
Is this preview feature also supported with mongoDB?
2color commentedon Sep 7, 2021
@andrelandgraf You cannot currently use
selectRelationCountwith the MongoDB connector.2color commentedon Sep 7, 2021
Closing this now that this has been released to General Availability in the 3.0.1 release