-
-
Notifications
You must be signed in to change notification settings - Fork 126
Closed
Labels
Milestone
Description
Description and expected behavior
I have a zmodel with inheritance. The base has a one to many relation. When quering the child, I am trying to use _count. However, it tries to find the relation in the child instead of the parent.
Environment (please complete the following information):
- ZenStack version: 2.1.2
- Prisma version: 5.13.0
- Database type: Postgresql
Additional context
The model
model Drink {
id Int @id @default(autoincrement())
slug String @unique
manufacturer_id Int
manufacturer Manufacturer @relation(fields: [manufacturer_id], references: [id])
type DrinkType
name String @unique
description String
abv Float
image String?
link String?
gluten Boolean
lactose Boolean
organic Boolean
containers Container[]
@@delegate(type)
@@allow('read', true)
@@allow('all', auth().type == Admin)
}
model Beer extends Drink {
style_id Int
style BeerStyle @relation(fields: [style_id], references: [id])
ibu Float?
glass Boolean @default(false)
@@allow('read', true)
@@allow('all', auth().type == Admin)
}The code
const beers = await dbe.beer.findMany({select: {id: true, name: true, _count: {select: {containers: true}}},orderBy: {name: "asc"}});
return json({beers});The error
Error calling enhanced Prisma method `beer.findMany`:
Invalid `prisma.beer.findMany()` invocation:
Unknown nested field '_count' for operation findManyBeer does not match any query.
at loader (/home/keewijk/projects/beer-inventory/app/routes/admin/edit/beer.tsx:14:32),
at async Object.callRouteLoader (/home/keewijk/projects/beer-inventory/node_modules/@remix-run/server-runtime/dist/data.js:62:16),
at async /home/keewijk/projects/beer-inventory/node_modules/@remix-run/router/dist/router.cjs.js:4229:21,
at async callLoaderOrAction (/home/keewijk/projects/beer-inventory/node_modules/@remix-run/router/dist/router.cjs.js:4294:16),
at async Promise.all (index 2),
at async callDataStrategyImpl (/home/keewijk/projects/beer-inventory/node_modules/@remix-run/router/dist/router.cjs.js:4169:17),
at async callDataStrategy (/home/keewijk/projects/beer-inventory/node_modules/@remix-run/router/dist/router.cjs.js:3702:19),
at async loadRouteData (/home/keewijk/projects/beer-inventory/node_modules/@remix-run/router/dist/router.cjs.js:3677:19),
at async queryImpl (/home/keewijk/projects/beer-inventory/node_modules/@remix-run/router/dist/router.cjs.js:3522:20),
at async Object.query (/home/keewijk/projects/beer-inventory/node_modules/@remix-run/router/dist/router.cjs.js:3416:18),
at async handleDocumentRequest (/home/keewijk/projects/beer-inventory/node_modules/@remix-run/server-runtime/dist/server.js:222:15),
at async requestHandler (/home/keewijk/projects/beer-inventory/node_modules/@remix-run/server-runtime/dist/server.js:141:18),
at async nodeHandler (/home/keewijk/projects/beer-inventory/node_modules/@remix-run/dev/dist/vite/plugin.js:844:27),
at async /home/keewijk/projects/beer-inventory/node_modules/@remix-run/dev/dist/vite/plugin.js:847:15 {
name: 'PrismaClientUnknownRequestError',
clientVersion: '5.13.0',
internalStack: 'Error calling enhanced Prisma method `beer.findMany`: \n' +
'Invalid `prisma.beer.findMany()` invocation:\n' +
'\n' +
'\n' +
"Unknown nested field '_count' for operation findManyBeer does not match any query.\n" +
' at Generator.next (<anonymous>),\n' +
' at fulfilled (/home/keewijk/projects/beer-inventory/node_modules/@zenstackhq/runtime/enhancements/proxy.js:6:58)'
}