MongoDB - Aggregation
MongoDB - Aggregation
Groups and transforms values from the documents of a MongoDB collection through an aggregation pipeline. It allows grouping, filtering, projection, calculations and sorting in a single operation. The results can be iterated with MongoDB: For each document.
Options
Collection
Reference to the MongoDB: Select collection action the aggregation pipeline will run on.
Aggregation pipeline
Aggregation pipeline in MongoDB array format, for example [{ "$match": { "status": "ativo" } }, { "$group": { "_id": "$categoria", "total": { "$sum": 1 } } }].
Transaction (optional)
Reference to a MongoDB: Start transaction action when the operation must run inside a transaction. Optional field, available under the advanced options.
Returns
Javascript code
js
actions["action-id"].aggregation // aggregation results (Any)
Field selection
- aggregation — results of the aggregation pipeline, usable by MongoDB: For each document (Any)
Rules and Conditions
- The Collection and Aggregation pipeline fields are required.
- The pipeline must be a valid JSON array following MongoDB's aggregation syntax.
- To iterate over the results, use the MongoDB: For each document action.