mongodb list all keys code example
Example: mongodb list all keys
var getKeys = function(collName) { var keys = {}; db.getCollection(collName).find().forEach(function(value) { Object.keys(value).forEach(function (keyName) { if(keys[keyName]) { keys[keyName] += 1; return; } keys[keyName] = 1; }); }); return keys; }
getKeys('zips')