# Rename Fields # false for upsert # true for multiple documents db..update({"": {$exists: true}}, {$rename:{"":""}}, false, true); # Merge two collections db.c1.find().forEach(function(item) { db.c2.insert(item); db.c1.remove(item); }); # Get Unique keys in a collection 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", ...]