by( )


Specifies how to group items in the result.

The by() method configures the aggregation pipeline to group items for which the specified expression resolves to the same value. The key and resolved expression determine the result item's unique _id property.

Note: When by() is not called or when it is called with no parameters, all items are placed in a single group.

Method Declaration
Copy
Method Parameters
expressionExpression

Expression to determine the grouping value. Items with matching values are grouped together. Learn more about using expressions in aggregation pipelines.


keystring

Name of the field in the result that contains the grouping value.

Returns
Return Type:GroupStage
Errors

This method doesn't return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?