Skip to content

Instantly share code, notes, and snippets.

@dotmh
Last active August 29, 2015 14:13
Show Gist options
  • Save dotmh/4748564b812f5208c0b4 to your computer and use it in GitHub Desktop.
Save dotmh/4748564b812f5208c0b4 to your computer and use it in GitHub Desktop.
design documents issue in pouchdb
function(doc) {
if ( doc.collection === "foobar") {
for(var i = 0; i < doc.belongsTo.length; ++i) {
var belongTo = doc.belongsTo[i];
if ( !!belongTo.length) {
emit(belongTo);
}
}
}
}
{
"_id" : "XXXX-XXXX-XXXX-XXXX",
"title" : "....",
"belongsTo" : [
"item1",
"item2",
"item3"
],
"collection" : "foobar"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment