diff --git a/packages/orm/src/client/crud-types.ts b/packages/orm/src/client/crud-types.ts index 329c55b8e..6c335cf93 100644 --- a/packages/orm/src/client/crud-types.ts +++ b/packages/orm/src/client/crud-types.ts @@ -1215,7 +1215,7 @@ export type FindArgs< : {}) : {}) & (AllowFilter extends true ? FilterArgs : {}) & - SelectIncludeOmit; + SelectIncludeOmit; export type FindManyArgs< Schema extends SchemaDef, diff --git a/tests/e2e/orm/client-api/find.test.ts b/tests/e2e/orm/client-api/find.test.ts index 5b6ab5639..75f684de3 100644 --- a/tests/e2e/orm/client-api/find.test.ts +++ b/tests/e2e/orm/client-api/find.test.ts @@ -1120,6 +1120,27 @@ describe('Client find tests ', () => { ).resolves.toMatchObject({ _count: { posts: 0 }, }); + + // typing + // user select allows _count because it has to-many relations + client.user.findMany({ + select: { _count: { select: { posts: true } } }, + }); + // nested author select allows _count because it has to-many relations + client.post.findMany({ + select: { + author: { + select: { + _count: { select: { posts: true } }, + }, + }, + }, + }); + // comment select does not allow _count because it has no to-many relations + client.comment.findMany({ + // @ts-expect-error + select: { _count: {} }, + }); }); it('supports _count inside include', async () => {