Created
August 3, 2016 14:56
-
-
Save StoneMoe/2d6302a324e104e12bd3ee43c0e8cc04 to your computer and use it in GitHub Desktop.
Mongodb manage commands gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mongodb get collection key names | |
mr = db.runCommand({ | |
"mapreduce" : "input_collection_name_here", | |
"map" : function() { | |
for (var key in this) { emit(key, null); } | |
}, | |
"reduce" : function(key, stuff) { return null; }, | |
"out": "input_collection_name_here" + "_keys" | |
}); | |
db[mr.result].distinct("_id"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment