Docs HomeMongoDB Compass

Import Pipeline from Text从文本导入管道

On this page本页内容

You can import aggregation pipelines from plain text into the Aggregation Pipeline Builder to easily modify and execute your pipelines. 您可以将纯文本聚合管道导入聚合管道生成器,以便轻松修改和执行管道。Importing a plain text aggregation pipeline shows how each stage of the pipeline affects the output, and illustrates the effects of modifying specific pipeline stages using the Pipeline Builder's Output panes.导入纯文本聚合管道显示管道的每个阶段如何影响输出,并说明使用管道生成器的“输出”窗格修改特定管道阶段的效果。

Note

Importing Pipelines From Text从文本导入管道

Starting in Compass 1.35, the import pipeline button has been removed from the Compass GUI. 从Compass 1.35开始,导入管道按钮已从Compass GUI中删除。The full functionality of importing pipelines from text is still supported as part of the View Pipeline as Text edit mode.作为“以文本形式查看管道”编辑模式的一部分,仍然支持从文本导入管道的全部功能。

Syntax语法

The imported pipeline must be:导入的管道必须是:

Procedure过程

1

In the aggregation pipeline pane, click the </> Text toggle switch to enable text mode for pipeline editing.在聚合管道窗格中,单击</> 文本切换开关以启用管道编辑的文本模式。

Toggle Textview Mode on
2

Type or paste an aggregation pipeline into the text editor. 在文本编辑器中键入或粘贴聚合管道。The text editor provides real-time linting for correct syntax and debugging information.文本编辑器提供实时linting以获取正确的语法和调试信息。

For example, the following pipeline consists of a single $limit stage:例如,以下管道由单个$limit阶段组成:

[ { "$limit" : 4 } ]
Edit aggregation pipeline

After you import your pipeline, you can click the {} Stages switch to return to stage view mode. 导入管道后,可以单击{}阶段开关返回到阶段视图模式。In this mode you can modify individual stages to see the results reflected in the Output of each respective stage.在此模式中,您可以修改各个阶段,以查看每个阶段的“输出”中反映的结果。