我在MongoDB中收集了以下表格.
[
{
"id" : 1,
},
{
"id" : 2,
},
{
"id" : 3
"xid": 300
}
]
I want to create a mongoexport statement that exports to a csv only documents with id's AND xid's with the value of xid > 0
我目前有以下命令:
mongoexport -h host -u user -p pass --db database --collection collections --csv --fields id,xid --query '{"xid":{"$ne":0}}' --out rec.csv
但是,这也会导出id不带xid的文档.所以我得到了
xid, id
12, 3
,4
14, 5
,3
,2
12, 5
等
有没有办法导出同时具有id和xid的文档?