Docs Home / Compass / Interact with Your Data / Query

Managing Saved Queries and Aggregations

Starting in MongoDB Compass 1.31, you can load saved queries and aggregations from the My Queries view once you are connected to your cluster. This page explains how to add and view favorite queries and aggregations.

Saving an Aggregation Pipeline

You can save a pipeline so that you can find it later. If you load a saved pipeline, you can change it without changing the original saved copy. You can also create a view from your pipeline results.

To save your pipeline:

1

Click the save dropdown button

In the Aggregations pane, click the Save drop-down menu and select Save as.

undefinedSave pipeline as
2

Enter a name for your pipeline

3

Save the pipeline

Click the Save button to save your pipeline. Your pipeline will be saved under the folder icon at the top left of the pipeline builder.

Saving a Favorite Query

You can favorite a query so that you can find it later. If you load a favorite query, you can change it without changing the original saved copy.

To add a query to your favorites:

1

Open query history

Click the History button on the query bar in the Documents pane.

Click history button
2

Select favorites

Hover over your query and click the Star button.

Click star button
3

Name your query

Enter a name for your query.

Viewing Saved Queries

Starting in MongoDB Compass 1.31, you can view your saved queries and aggregation pipelines on the My Queries tab once connected to your cluster.

Using the My Queries Tab

When you click a saved or favorite query tile, Compass opens the Documents tab with the filter loaded.

When you click a saved or favorite pipeline tile, Compass opens the Aggregations tab with the pipeline loaded.

Using the Favorites Tab

You can also view favorite queries from the Favorites tab from in the Documents view. To open the Favorites tab:

1

Open query history

Click the History button at the top of the Documents tab.

Query history view
2

Click the Favorites button in the past queries pane.

Select your favorited operation.

  • If your favorited operation is a query, only a Filter statement displays in the Favorites list view along with copy and delete icons.

    Note

    Clicking a favorited query in the Favorites list view populates your Query Bar with that query.

  • If your favorited operation is a bulk update statement, a Filter and Update statement display in the Favorites list view along with copy , delete , and open in modal icons.

    Note

    Clicking the icon opens the bulk update statement and the filter criteria in the Update Documents modal. For details on bulk update statements in Compass, see Modify Multiple Documents.

Viewing Query History

For details on how to view query history see viewing recent query history.