Skip to content

Instantly share code, notes, and snippets.

@ssp
Last active December 29, 2015 08:09
Show Gist options
  • Save ssp/7641589 to your computer and use it in GitHub Desktop.
Save ssp/7641589 to your computer and use it in GitHub Desktop.
CouchDB Map function to output object key paths
function(doc) {
var process = function (item, keyPath) {
if (typeof(item) === 'object' && !isArray(item)) {
for (var i in item) {
newPath = keyPath.slice();
newPath.push(i);
process(item[i], newPath);
}
}
else {
emit(keyPath);
}
}
process(doc, []);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment