![mongoexport csv 输出数组值](https://linux22.com/image/1343366/mongoexport%20csv%20%E8%BE%93%E5%87%BA%E6%95%B0%E7%BB%84%E5%80%BC.png)
我正在使用 mongoexport 将一些集合导出到 CSV 文件中,但是当我尝试定位数组成员的字段时,我无法正确导出它。
我正在使用的命令:
mongoexport -d db -c collection -fieldFile fields.txt --csv > out.csv
fields.txt 的内容类似于
id
name
address[0].line1
address[0].line2
address[0].city
address[0].country
address[0].postcode
BSON 数据如下:
{
"id": 1,
"name": "example",
"address": [
{
"line1": "flat 123",
"line2": "123 Fake St.",
"city": "London",
"country": "England",
"postcode": "N1 1AA"
}
]
}
导出数组内容的正确语法是什么?
答案1
字段应该
id
name
address.0.line1
address.0.line2
address.0.city
address.0.country
address.0.postcode