Docs HomeMongoDB Compass

Export Pipeline to Specific Language将管道导出为特定语言

New in version 1.15.01.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.您可以使用聚合管道生成器将完成的管道导出为支持的语言之一;Java、Node、C#和Python 3。此功能便于格式化和导出在MongoDB Compass中创建的管道,以便在应用程序中使用。

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.创建新管道或打开现有管道。

For instructions on creating an aggregation pipeline in MongoDB Compass, see Aggregation Pipeline Builder.有关在MongoDB Compass中创建聚合管道的说明,请参阅聚合管道生成器

3

Click the Export button.单击“导出”按钮。

Aggregation Builder export dropdown
4

Select your desired export language.选择所需的导出语言。

In the Export Pipeline To: dropdown, select your desired programming language:在“将管道导出到:”下拉列表中,选择所需的编程语言:

Aggregation Builder language select

The My Pipeline pane on the left displays your pipeline in mongo shell syntax.左侧的“我的管道”窗格以mongo shell语法显示您的管道。

The pane to the right displays your pipeline in the selected programming language.右侧的窗格显示所选编程语言的管道。

5

Optional: Include import statements, if desired.可选:如果需要,包括导入语句。

Check the Include Import Statements option to include the required import statements for the selected programming language.选中“包含导入语句”选项以包含所选编程语言所需的导入语句。

6

Optional: Include driver syntax, if desired.可选:如果需要,包括驱动程序语法。

Check the Include Driver Syntax option to include application code for the selected programming language. 选中“包含驱动程序语法”选项以包含所选编程语言的应用程序代码。If you include driver syntax, the copyable code reflects project, sort, maxtimems, collation, skip and limit options.如果包含驱动程序语法,则可复制代码会反映projectsortmaxtimemscollationskiplimit选项。

7

Click .点击

Click at the top-right of the pipeline to copy the pipeline for the selected programming language to your clipboard. 单击管道右上角的,将所选编程语言的管道复制到剪贴板。You can now integrate and execute your created pipeline into your application.现在,您可以将创建的管道集成并执行到应用程序中。

8

Click Close.单击“关闭”。