mongoexport 根据objectid导出数据 --query _id
参考资料
https://docs.mongodb.com/database-tools/mongoexport/#options
https://docs.mongodb.com/v4.2/reference/mongodb-extended-json/
mongo的资料是真的少的可怜,全得自己翻文档
给四个例子看下就懂了
根据id导出数据
windows
mongoexport --uri=mongodb://xxxx:27017/xxx -c jetcache_cache_info --type=csv -o G://export/xxx.jetcache_cache_info.csv -f _id,cacheName,cacheType,qps,rate,get,hit,fail,expire,avgLoadTime,maxLoadTime,createTime --query "{\"_id\" : {\"$oid\": \"609c9d754cedfd000126871c\"}}"
linux
mongoexport --uri=mongodb://xxxx:27017/xxx -c jetcache_cache_info --type=csv -o G://export/xxx.jetcache_cache_info.csv -f _id,cacheName,cacheType,qps,rate,get,hit,fail,expire,avgLoadTime,maxLoadTime,createTime --query '{"_id" : {"$oid": "609c9d754cedfd000126871c"}}'
根据id范围导出数据
windows
mongoexport --uri=mongodb://xxxx:27017/xxx -c jetcache_cache_info --type=csv -o G://export/xxx.jetcache_cache_info.csv -f _id,cacheName,cacheType,qps,rate,get,hit,fail,expire,avgLoadTime,maxLoadTime,createTime --query "{\"_id\":{\"$lte\":{\"$oid\":\"609c9d754cedfd000126871c\"}}}"
linux
mongoexport --uri=mongodb://xxxx2:27017/xxx -c jetcache_cache_info --type=csv -o G://export/xxx.jetcache_cache_info.csv -f _id,cacheName,cacheType,qps,rate,get,hit,fail,expire,avgLoadTime,maxLoadTime,createTime --query '{"_id":{"$lte":{"$oid":"609c9d754cedfd000126871c"}}}'