Currently, aggregates only work with groupBy which means we can't write collection-wide aggregates like in this snippet:
const aggregateQuery = queryBuilder()
.from({ collection })
.select({
rows: { COUNT: `@id` },
avg_age: { AVG: `@age` },
})
A possible implementation strategy would be to have select check if there is a groupBy clause and if not add a default groupBy that groups by null to have a collection-wide groupBy.
Currently, aggregates only work with
groupBywhich means we can't write collection-wide aggregates like in this snippet:A possible implementation strategy would be to have
selectcheck if there is agroupByclause and if not add a defaultgroupBythat groups bynullto have a collection-wide groupBy.