Docs Home / Compass / Create an Aggregation Pipeline

Export Aggregation Pipeline Results导出聚合管道结果

To use your aggregated data in other external tools, you can export your pipeline results from MongoDB Compass as a JSON or CSV file.要在其他外部工具中使用聚合数据,您可以将MongoDB Compass的管道结果导出为JSON或CSV文件。

About this Task关于此任务

Avoid using CSV files exports to back up your data. CSV files may lose type information and are not suitable for backing up your data.避免使用CSV文件导出来备份数据。CSV文件可能会丢失类型信息,不适合备份数据。

Steps步骤

1

Click Export单击“导出”

In the top right of the aggregation pipeline builder, click the Export button to open the modal.在聚合管道生成器的右上角,单击导出按钮打开模式。

Export button on aggregation pipeline
2

Choose the file type for your export选择导出的文件类型

Under Export File Type, select either JSON or CSV. If you select JSON, your data is exported to the target file as an array of JSON objects.在“导出文件类型”下,选择JSONCSV。如果选择JSON,则数据将作为JSON对象数组导出到目标文件。

3

(Optional) Choose an advanced JSON format option(可选)选择高级JSON格式选项

If choose to export your data as a JSON file, you can expand the Advanced JSON Format drop-down menu and select from the following extended JSON formats:如果选择将数据导出为JSON文件,您可以展开“高级JSON格式”下拉菜单,并从以下扩展JSON格式中进行选择:

JSON FormatJSON格式Description描述Sample Document示例文档
Default Extended JSON默认扩展JSONA string format that avoids any loss of BSON type information. This is the default Compass setting.一种避免丢失BSON类型信息的字符串格式。这是默认的Compass设置。
{
"fortyTwo" : 42,
"oneHalf" : 0.5,
"bignumber" : {
"$numberLong" : "5000000000"
}
}
Relaxed Extended JSON宽松的扩展JSON

A string format that emphasizes readability and interoperability at the expense of type preservation. That is, conversion from relaxed format to BSON can lose type information.一种以牺牲类型保留为代价强调可读性和互操作性的字符串格式。也就是说,从宽松格式转换为BSON可能会丢失类型信息。

WARNING:警告 This format is not recommended for data integrity.不建议使用此格式来保证数据完整性。

{
"fortyTwo" : 42,
"oneHalf": 0.5,
"bignumber" : 5000000000
}
Canonical Extended JSON标准扩展JSONA string format that emphasizes type preservation at the expense of readability and interoperability. 一种以牺牲可读性和互操作性为代价强调类型保留的字符串格式。That is, conversion from canonical to BSON will generally preserve type information except in certain specific cases.也就是说,从规范到BSON的转换通常会保留类型信息,除非在某些特定情况下。
{
"fortyTwo" : {
"$numberInt" : "42"
},
"oneHalf" : {
"$numberDouble" : "0.5"
},
"bignumber" : {
"$numberLong" : "5000000000"
}
}
4

Click Export单击“导出”

5

Specify export destination指定导出目标

In the new pop-up modal, enter a name for your export file, specify the file destination, and click Select to export your pipeline results.在新的弹出模式中,输入导出文件的名称,指定文件目标,然后单击“选择”导出管道结果。

Learn More了解更多