侃侃无极
您可以使用MapReduce完成此操作:mr = db.runCommand({
"mapreduce" : "my_collection",
"map" : function() {
for (var key in this) { emit(key, null); }
},
"reduce" : function(key, stuff) { return null; },
"out": "my_collection" + "_keys"})然后对结果集合执行不同的操作,以便查找所有键:db[mr.result].distinct("_id")["foo", "bar", "baz", "_id", ...]