Created
March 14, 2018 18:37
-
-
Save carloshanson/c8eee84eb6510cfbd49db1d1da9f8dc6 to your computer and use it in GitHub Desktop.
emit document matching properties of an object
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
// CouchDB document | |
{ | |
"_id": "e44f991ff6d04174bb932fcfcb0008aa", | |
"_rev": "2-f4f2de9cb942435a9213f0f2cd09d902", | |
"user": "user1", | |
"key_level1": { | |
"abc": { | |
"type": "text" | |
}, | |
"bcc": { | |
"type": "text" | |
} | |
} | |
} | |
// View to return user and type | |
function(doc) { | |
if (doc.user) { | |
for each (var item in doc.key_level1) { | |
if (item.type === 'text') { | |
emit([doc.user, item.type], doc); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment