mongodb list all fields

mr = db.runCommand({
  "mapreduce" : "user_data",
  "map" : function() {
    for (var key in this) { emit(key, null); }
  },
  "reduce" : function(key, stuff) { return null; }, 
  "out": "user_data" + "_keys"
})
db[mr.result].distinct("_id")
http://stackoverflow.com/questions/2298870/mongodb-get-names-of-all-keys-in-collection
 
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment