Aggregations for counting associations


I have a articles model with a one to many category association. I would like to count the amount of articles for each category but there doesn’t seem to be a way to do aggregations. Does anyone have a solution to this?

Thank you very much in advance!

1 Like

hello @sysadmin welcome to Community :slight_smile:

I think that you can do what you need by querying the _allArticlesMeta (for example, not sure what’s your model name), filtering with the IDs of the category and getting the count, something like this I guess:

_allArticlesMeta(filter: {cateogry: {anyIn: "123"}}) {

Ok, then two queries are required to do this, and it is not possible to do it using just one?

Yes, I think so