Last active
December 29, 2015 14:19
-
-
Save citmusa/7682959 to your computer and use it in GitHub Desktop.
MONGO DB
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
db.collection.find({ query },{"field to show": true, "field to show": true}) | |
db.collection.find({ query },{"field to show": true, "_id": false }) | |
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
db.products.find({"field_name":{$exists:true}}) |
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
mr = db.runCommand({ | |
"mapreduce" : "collection_name", | |
"map" : function() { | |
for (var key in this) { emit(key, null); } | |
}, | |
"reduce" : function(key, stuff) { return null; }, | |
"out": "things" + "_keys" | |
}) | |
#Then run | |
db[mr.result].distinct("_id") | |
["foo", "bar", "baz", "_id", ...] |
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
db.collection.update({ query }, { $rename: { "old name": "new name" }}, false, true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment