Dan M
05/04/2021, 8:35 PMType '{ _count: { select: { initialLadderAppearances: true; }; }; }' is not assignable to type 'MemberInclude'.
Object literal may only specify known properties, and '_count' does not exist in type 'MemberInclude'.ts(2322)
I just verified that I generated my Prisma client using 2.22.0, and I reloaded VSCode. _count
doesn't seem to exist anywhere 🤷♂️🤷♂️🤷♂️
Here's the relevant code snippet:Robert Witchell
05/05/2021, 12:44 AMDan M
05/05/2021, 6:50 AMRobert Witchell
05/05/2021, 6:54 AMRobert Witchell
05/05/2021, 6:55 AMRobert Witchell
05/05/2021, 6:57 AMDan M
05/05/2021, 8:09 AMgenerator client {
provider = "prisma-client-js"
previewFeatures = ["selectRelationCount"]
}
Alas, now that I have it working, it doesn't quite do what I want (or I don't know how yet).
Essentially, you can do this:
const member = await prisma.member.findUnique({
select: {
initialLadderAppearances: {
where: {
year: { gte: currentYear },
},
},
},
where: { id: memberId },
});
But you can't do this...
const member = await prisma.member.findUnique({
select: {
_count: {
select: {
initialLadderAppearances: {
where: {
year: { gte: currentYear },
},
},
},
},
},
where: { id: memberId },
});
Maybe there's a way, but this isn't the syntax if there is.Robert Witchell
05/05/2021, 8:13 AMsome
syntax when working with relations. See these threads: https://prisma.slack.com/archives/CKQTGR6T0/p1620000893084500?thread_ts=1619164287.276100&cid=CKQTGR6T0Robert Witchell
05/05/2021, 8:15 AMDan M
05/05/2021, 8:16 AMsome
is interesting.
I got my particular problem solved with selects and just did a little bit of post-processing with the result.Dan M
05/05/2021, 8:17 AMRobert Witchell
05/05/2021, 9:32 AM