Created
May 5, 2014 19:26
-
-
Save nolanlawson/31852994778dbb1daaf2 to your computer and use it in GitHub Desktop.
pouchdb_mapreduce_example.js
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
// 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