Group uses ConstantsTrait
Vocabulary of the high-level grouping spec consumed by {@see \oihana\arango\models\traits\aql\GroupTrait::prepareCollect()}.
It is the COLLECT counterpart of Facet: a short, request-friendly
spec — by / agg / count / alt / sort — translated into the raw
aqlCollect() spec. It reuses the existing
engines: FacetAggregator for the
aggregate functions and the alt engine
(alterExpression()) for grouping-key transforms.
Held by the Arango::GROUP key of a list query.
Tags
Table of Contents
Constants
- AGG : string = 'group_agg'
- The aggregates: `[ outName => 'func:field' ]` or `[ outName => [ func, field ] ]`, where `func` is a {@see \oihana\arango\models\enums\facets\FacetAggregator} code (`sum`, `avg`, `min`, `max`). E.g. `[ 'total' => 'sum:amount' ]` → `total = SUM(doc.amount)`.
- ALT : string = 'group_alt'
- The `alt` transformation chains applied to grouping keys, keyed by group variable name: `[ 'year' => 'dateYear' ]` → `year = DATE_YEAR(doc.created)`.
- BY : string = 'group_by'
- The grouping field(s). Accepts a CSV string (`'category'`, `'category,status'`), a list (`['category','status']`), or an explicit `[ varName => field ]` map (`['year' => 'created']`). Dotted fields become underscore variable names (`address.city` → `address_city` reading `doc.address.city`).
- COUNT : string = 'group_count'
- The per-group count. `true` adds `WITH COUNT INTO count`; a string sets the variable name. When aggregates are present it is emitted as `name = LENGTH(1)` instead (AGGREGATE and WITH COUNT being mutually exclusive in AQL).
- COUNT_NAME : string = 'count'
- Default variable name used when {@see Group::COUNT} is `true`.
- FIELD : string = 'field'
- The aggregate function code inside an array aggregate definition (`[ Group::FUNC => 'sum', Group::FIELD => 'amount' ]`).
- FUNC : string = 'func'
- SORT : string = 'group_sort'
- The sort applied to the grouped result, on group/aggregate variable names (never on `doc`, which is out of scope after COLLECT). CSV with a leading `-` for descending: `'-count'`, `'category,-total'`.
Constants
AGG
The aggregates: `[ outName => 'func:field' ]` or `[ outName => [ func, field ] ]`, where `func` is a {@see \oihana\arango\models\enums\facets\FacetAggregator} code (`sum`, `avg`, `min`, `max`). E.g. `[ 'total' => 'sum:amount' ]` → `total = SUM(doc.amount)`.
public
string
AGG
= 'group_agg'
ALT
The `alt` transformation chains applied to grouping keys, keyed by group variable name: `[ 'year' => 'dateYear' ]` → `year = DATE_YEAR(doc.created)`.
public
string
ALT
= 'group_alt'
Same engine as the filter/facet alt.
BY
The grouping field(s). Accepts a CSV string (`'category'`, `'category,status'`), a list (`['category','status']`), or an explicit `[ varName => field ]` map (`['year' => 'created']`). Dotted fields become underscore variable names (`address.city` → `address_city` reading `doc.address.city`).
public
string
BY
= 'group_by'
COUNT
The per-group count. `true` adds `WITH COUNT INTO count`; a string sets the variable name. When aggregates are present it is emitted as `name = LENGTH(1)` instead (AGGREGATE and WITH COUNT being mutually exclusive in AQL).
public
string
COUNT
= 'group_count'
COUNT_NAME
Default variable name used when {@see Group::COUNT} is `true`.
public
string
COUNT_NAME
= 'count'
FIELD
The aggregate function code inside an array aggregate definition (`[ Group::FUNC => 'sum', Group::FIELD => 'amount' ]`).
public
string
FIELD
= 'field'
FUNC
public
string
FUNC
= 'func'
Tags
SORT
The sort applied to the grouped result, on group/aggregate variable names (never on `doc`, which is out of scope after COLLECT). CSV with a leading `-` for descending: `'-count'`, `'category,-total'`.
public
string
SORT
= 'group_sort'