我有一个包含以下文档的MongoDB集合。有些文档有一个字段,另一些有两个字段。我想只将那些有两个字段的文件导出到CSV文件中。我可以使用什么查询来排除那些有一个字段的查询?
[
{
"id" : 1,
},
{
"id" : 2,
},
{
"id" : 3
"productId": 300
}
]我的mongoexport命令是:mongoexport --username x --password x --host x --db mydb --collection mycol --type=csv --fields id,productid --out "c:\myfile.csv"
发布于 2016-04-01 05:41:21
尝试一下我添加了查询的这个
mongoexport --username x --password x --host x --db mydb --collection mycol --type=csv --fields id,productid --query '{ "$and": [ { "id": {"$exists":true}},{"productId":{"$exists":true}}] }' --out "c:\myfile.csv"或者可能是
mongoexport --username x --password x --host x --db mydb --collection mycol --type=csv --fields id,productid --query '{ "id": {"$exists":true},"productId":{"$exists":true} }' --out "c:\myfile.csv"https://stackoverflow.com/questions/36348527
复制相似问题