Skip to content

Instantly share code, notes, and snippets.

@ringmaster
Created February 9, 2012 05:46
Show Gist options
  • Save ringmaster/1777673 to your computer and use it in GitHub Desktop.
Save ringmaster/1777673 to your computer and use it in GitHub Desktop.
Get all items from a test
db.tests.remove({slug: "foo"})
db.tests.insert({slug: "foo", forms: [ {slug: "section 1", clusters: [
{slug: "cluster 1", items: [1,2,3]},
{slug: "cluster 2", items: [4,5,6]}
]}]});
var map = function() {
this.forms.forEach(function(form){
form.clusters.forEach(function(cluster){
cluster.items.forEach(function(item){
emit(item, item);
})
})
})
};
function (key, values) {
return values;
}
db.tests.mapReduce(map, reduce, {query: {slug: "foo"}, out: {inline: 1} });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment