Created
February 9, 2012 05:46
-
-
Save ringmaster/1777673 to your computer and use it in GitHub Desktop.
Get all items from a test
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
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