prisma-client-go
prisma-client-go copied to clipboard
Is there a Count() function?
I saw the official doc: https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/crud#count have count()
definition. But not found in the prisma-client-go.
Unfortunately the go client does not support that yet, you'll have to use a raw query instead until we add this feature to the go client.
All right, thank you 💯
One thing I'd love to see is a count of relations.
posts, err := d.db.Post.
FindMany(filters...).
With(
db.Post.Author.Fetch(),
db.Post.Tags.Fetch(),
db.Post.Category.Fetch(),
db.Post.Comments.Fetch().Count(), // Outputs a count of items in the Posts[] relation
).
Take(max).
OrderBy(db.Post.CreatedAt.Order(db.Direction(sort))).
Exec(ctx)
// posts.CommentsCount or something would now contain a the number of comments linked with each post
That's a good point. I'll bump this internally.