Skip to content

Instantly share code, notes, and snippets.

@dustin
Created May 23, 2011 18:05
Show Gist options
  • Save dustin/987178 to your computer and use it in GitHub Desktop.
Save dustin/987178 to your computer and use it in GitHub Desktop.
allkeys
function(doc) {
for (var k in doc) {
if (k[0] != '_') {
var val = doc[k];
if (isArray(val)) {
val.forEach(function(i) {
emit([k, i], null);
});
} else if (typeof(val) == 'object') {
emit([k, '<object>'], null);
} else {
emit([k, val], null);
}
}
}
}
function(doc) {
["addedby", "taken", "ts"].forEach(function(k) {
if (doc[k]) {
emit([k, doc[k]], null);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment