nicklasos
12/12/2014 - 10:51 AM

mongodb all fields in db

mongodb all fields in db

// Show all fields in db
var mr = db.runCommand({
  "mapreduce" : "events",
  "map" : function() {
    for (var key in this) { emit(key, null); } // this.nestedArray (for nested fields)
  },
  "reduce" : function(key, stuff) { return null; }, 
  "out": "events_keys"
});

db[mr.result].distinct("_id")