On this page



Executes a MongoDB aggregation pipeline on a collection and returns the results.


In order to use MongoDB service actions, you must have rules set up for each namespace included in the operation.

You can only use the aggregate action in the first stage of a pipeline. The aggregate action stage has the following syntax:

     "database": <dbname>,
     "collection": <collection name>,
     "pipeline":[<aggregation stage1>, ...]

The aggregate action takes the following arguments:

Argument Type Description
database string Name of the database.
collection string Name of the collection.
pipeline array The aggregation pipeline stages.


Consider the following pipeline that performs an aggregation pipeline on the specified collection:


Stage1: The MongoDB aggregate stage first groups the documents by the customer and item fields and then writes the grouped documents into the my_db.reports collection.