Docs HomeMongoDB Compass

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. 从MongoDB Compass 1.31开始,一旦连接到集群,就可以从My queries视图加载保存的查询和聚合。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单击保存下拉按钮

Click the Save dropdown button at the top of the pipeline builder. 单击管道生成器顶部的“保存”下拉按钮。Click on Save pipeline as...单击“将管道另存为…”。

Save pipeline as
2

Enter a name for your pipeline输入管道的名称

Name your pipeline
3

Click Save单击“保存”

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.单击查询栏上的“历史记录”按钮。

Click history button
2

Select favorites选择收藏夹

Click the Star button.单击“星形”按钮。

Click star button
3

Name your query命名您的查询

Enter a name for your query.输入查询的名称。

Save favorite query

Viewing Saved Queries查看保存的查询

Starting in MongoDB Compass 1.31, you can view your saved queries and aggregation pipelines on the My Queries view once connected to your cluster.从MongoDB Compass 1.31开始,连接到集群后,您可以在“我的查询”视图中查看保存的查询和聚合管道。

Using the My Queries View使用“我的查询”视图

When you click a saved or favorite query tile, Compass opens the Documents tab with the filter loaded.当您单击已保存或喜爱的查询磁贴时,Compass会打开加载了筛选器的“文档”选项卡。

When you click a saved or favorite pipeline tile, Compass opens the Aggregations tab with the pipeline loaded.单击已保存或喜爱的管道磁贴时,Compass会打开加载了管道的“聚合”选项卡。

My queries view

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 favorite queries.选择常用查询。

Viewing Query History查看查询历史记录

For details on how to view query history see viewing recent query history.有关如何查看查询历史记录的详细信息,请参阅查看最近的查询历史记录