Last active
December 29, 2015 08:09
-
-
Save ssp/7641589 to your computer and use it in GitHub Desktop.
CouchDB Map function to output object key paths
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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