如何将mongodb查询导出到csv

如何将mongodb查询导出到csv,mongodb,mongodb-query,mongoexport,Mongodb,Mongodb Query,Mongoexport,无法使用mongoDb在linux服务器上执行以下查询 mongoexport --db MongoLog --collection dCDMongoLog --query '{$and:[{'jsonObject.responseRaw':{$regex:'<Amount>1000'}},{'jsonObject.createDate':{$gt:'2021-04-01'}},{'jsonObject.createDate':{$lte:'2021-04-08'}}]}' --cs

无法使用mongoDb在
linux
服务器上执行以下查询

mongoexport --db MongoLog --collection dCDMongoLog --query '{$and:[{'jsonObject.responseRaw':{$regex:'<Amount>1000'}},{'jsonObject.createDate':{$gt:'2021-04-01'}},{'jsonObject.createDate':{$lte:'2021-04-08'}}]}' --csv -f jsonObject.mobile,jsonObject.createDate --out /opt/data1234.csv
甚至试过这样做:

mongoexport -d MongoLog -c dCDMongoLog -q "{$and:[{'jsonObject.responseRaw':{$regex:'<Amount>1000'}},{'jsonObject.createDate':{$gt:'2021-04-01'}},{'jsonObject.createDate':{$lte:'2021-04-08'}}]}" -f jsonObject.mobile,jsonObject.createDate --type=csv > /opt/data1234.csv

似乎什么也没有发生。还有其他方法吗?

mongoexport
查询太糟糕了!它需要外部单引号和内部双引号。 下面的命令对我有用

mongoexport -d MongoLog -c dCDMongoLog -q '{"$and":[{"jsonObject.responseRaw":{$regex:"<Amount>1000"}},{"jsonObject.createDate":{$gt:"2021-04-01"}},{"jsonObject.createDate":{$lte:"2021-04-08"}}]}' -f jsonObject.mobile,jsonObject.createDate --type=csv > /opt/data1235.csv
mongoexport-d mongog-c dCDMongoLog-q'{“$and”:[{“jsonObject.responseRaw”:{$regex:“1000”},{“jsonObject.createDate”:{$gt:“2021-04-01”},{“jsonObject.createDate”:{$lte:“2021-04-08”}}'-f jsonObject mobile,jsonObject.createDate--type=csv>/opt/1235.csv
 error validating settings: query '[123 58 91 123 39 106 115 111 110 79 98 106 101 99 116 46 114 101 115 112 111 110 115 101 82 97 119 39 58 123 58 39 60 65 109 111 117 110 116 62 49 48 48 48 39 125 125 44 123 39 106 115 111 110 79 98 106 101 99 116 46 99 114 101 97 116 101 68 97 116 101 39 58 123 58 39 50 48 50 49 45 48 52 45 48 49 39 125 125 44 123 39 106 115 111 110 79 98 106 101 99 116 46 99 114 101 97 116 101 68 97 116 101 39 58 123 58 39 50 48 50 49 45 48 52 45 48 56 39 125 125 93 125]' is not valid JSON: invalid character ':' looking for beginning of object key string
2021-04-16T20:01:00.729-0400    try 'mongoexport --help' for more information
mongoexport -d MongoLog -c dCDMongoLog -q '{"$and":[{"jsonObject.responseRaw":{$regex:"<Amount>1000"}},{"jsonObject.createDate":{$gt:"2021-04-01"}},{"jsonObject.createDate":{$lte:"2021-04-08"}}]}' -f jsonObject.mobile,jsonObject.createDate --type=csv > /opt/data1235.csv