omar-dulaimi / prisma-trpc-generator

Prisma 2+ generator to emit fully implemented tRPC routers
MIT License
665 stars 31 forks source link

Prisma Count API #81

Open imsanchez opened 1 year ago

imsanchez commented 1 year ago

Problem

The generator does not include the count API.

image

Use count to count the number of records or non-null field values. The following example query counts all users:

const userCount = await prisma.user.count()

https://www.prisma.io/docs/concepts/components/prisma-client/aggregation-grouping-summarizing#count

Suggested solution

I will create a pull request to add the API.

Alternatives

None I can think of as of now ~ open to suggestions.

Additional context

This was brought to our attention via ZenStack: https://github.com/zenstackhq/zenstack/issues/618

ymc9 commented 1 year ago

Hi @imsanchez , have you already put any effort into this one? I'm wondering if I should start the work form ZenStack side.

imsanchez commented 11 months ago

Sorry @ymc9 , I have not. Swamped with personal things and just got back. I saw you fixed it from the ZenStack side, thank you!! 🎉