Add sorting + aggregations docs
Describe the Request
Currently in the directus documentation, there is nothing (or I have not found it) regarding how to order the results through aggregated fields. After looking at the code and finding this PR: https://github.com/directus/directus/pull/19568, I realized that you could sort by, for example, a "count" result in descending order.
Example with SDK:
{
aggregate: {
count: 'id',
},
groupBy: ['company'],
query: {
sort: ['count.id']
}
}
This would sort the result of count.id in descending order.
It would be great if this was added to the documentation in some way, since, currently from my point of view, there is a lot of information missing regarding how to take advantage of aggregation and grouping.
Maintainence Strategy
Every time the sorting strategy is changed in the aggregation.
Thank you @cgm164 ! Your research appeared to be very helpful cause I've already given up on attempting to sort by an aggregate field now I have learned the correct syntax.