scenario - there is an Article content type. Each article has a relation to the Likes table (1-N - Article belongs to many Likes). When I query for articles, I want to get the number of likes for each article. Furthermore, I want to be able to sort by the count of likes (thus querying “The most liked…”).
This is a super common scenario I guess, but I don’t see an easy way in Strapi to achieve this. Even in v4, there’s no count metadata for relation fields.
So what’s the best approach to be able to easily:
- get number of likes related to the Article
- sort articles by the number of likes