Mixin: Grouping

Grouping

This mixin grants aggregation capabilities to a statement instance via composition.

Methods


groupBy( [searchExprStrList])

Picks one or more document fields or table columns to be aggregated in the result set. This method does not cause the statement to be executed but changes the statement boundaries, which means that if it has been prepared before, it needs to be re-prepared.
Parameters:
Name Type Argument Description
searchExprStrList SearchExprStrList <optional>
<repeatable>
The name of the table columns or document fields to include in the aggregation.
Returns:
The instance of the statement itself following a fluent API convention.
Type
Grouping
Example
// arguments as columns group by
const query = table.select('foo', 'bar').groupBy('foo asc', 'bar desc')

// array of columns to group by
const query = table.select('foo', 'bar').groupBy(['foo asc', 'bar desc'])

having(searchConditionStr)

Defines the aggregation criteria for the current statement. This method does not cause the statement to be executed but changes the statement boundaries, which means that if it has been prepared before, it needs to be re-prepared.
Parameters:
Name Type Description
searchConditionStr SearchConditionStr The aggregation criteria specified as a string or an X DevAPI expression.
Returns:
The instance of the statement itself following a fluent API convention.
Type
Grouping