MongoDB: export distinct column value
问题 Anyone have idea how to export distinct column value on mongodb using mongoexport command. Command: db.coll.distinct("uid"); The solution i have tried is : mongoexport --csv -d db -c collection -q '{distinct: "collection", "key": "uid"}' -f "uid" -o distinctUid.csv 回答1: It's not possible to do it this way. distinct is a database command, and --query option allows to use only a query to filter documents. If you are using mongodb v3.4 or later, you can use views to aggregate your collection and