Navigation

Export Pipeline to Specific Language

New in version 1.15.0

You can use the Aggregation Pipeline Builder to export your finished pipeline to one of the supported languages; Java, Node, C#, and Python 3. This feature facilitates formatting and exporting pipelines created in MongoDB Compass for use in your applications.

Procedure

1

Open the Aggregation Pipeline Builder for the desired collection.

Navigate to the collection for which you wish to export your aggregation pipeline. Click the Aggregations tab.

2

Create a new pipeline or open an existing one.

After constructing or opening an aggregation pipeline, click the button to the right of the Save Pipeline button.

Note

For instructions on creating an aggregation pipeline in MongoDB Compass, see Aggregation Pipeline Builder.

3

Select Export to Language.

Aggregation Builder export dropdown
4

Select your desired export language.

In the Export Pipeline To: dropdown, select your desired language:

Aggregation Builder language select

The My Pipeline pane on the left displays your pipeline in mongo shell syntax.

The pane to the right displays your pipeline in the language selected.
5

Include import statements, if desired.

(Optional): Check the Include Import Statements option to include the required import statements for the language selected.

6

Click Copy.

Click the Copy button at the top-right of the pipeline to copy the pipeline for the selected language to your clipboard. You can now integrate and execute your created pipeline into your application.

7

Click Close.

Click Close to return to the aggregation pipeline builder.