citmusa
11/27/2013 - 8:49 PM

MONGO DB

MONGO DB

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", ...]
db.collection.update({ query }, { $rename: { "old name": "new name" }}, false, true)
db.products.find({"field_name":{$exists:true}})
db.collection.find({ query },{"field to show": true, "field to show": true})

db.collection.find({ query },{"field to show": true, "_id": false })