Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Created May 5, 2014 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nolanlawson/31852994778dbb1daaf2 to your computer and use it in GitHub Desktop.
Save nolanlawson/31852994778dbb1daaf2 to your computer and use it in GitHub Desktop.
pouchdb_mapreduce_example.js
// from http://pastebin.com/QrY2VALX
var t = ['thor', 'loki'];
function map(doc) {
if (doc.type == "teammember") { // no need to check for the team member here; use keys instead
emit(doc._id); // no need to emit 'doc' as a value, just use include_docs=true
}
}
this.db.query({
map: map
}, {
reduce: false,
keys: ['thor', 'loki'],
include_docs: true
}, function(err, resp) {
//should return object with doc.type == "teammember" and doc.name == 'thor' or 'loki'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment