Aggregate Results with Full Data Objects Â
AGGREGATE_BY organizes query results into groups based on one or more property values, returning both count summaries and the full data objects for each group.AGGREGATE_BY returns the full data objects grouped by the specified properties, providing both count and the actual grouped elements for detailed analysis. This is useful when you need to work with the actual data in each group, not just counts.
When using the SDKs or curling the endpoint, the query name must match what is defined in the
queries.hx file exactly.Example 1: Aggregate orders by status
Example 2: Aggregate products by category with COUNT
When to Use AGGREGATE_BY vs GROUP_BY
Choose AGGREGATE_BY when:- You need the actual data objects in each group
- You want to perform further processing on grouped items
- You need to display or return the full records
- You’re building reports that show detailed breakdowns
- You only need counts and summaries
- Memory efficiency is a priority
- You’re doing analytics or dashboards showing distributions
- You don’t need the actual data, just statistics
AGGREGATE_BY returns more data than GROUP_BY, so it uses more memory and bandwidth. Use GROUP_BY when you only need counts.