I want to find out what's the occurrence of lastnames in a collection. I'm using the following:
m = function() { this.lastname.forEach( function(z) { emit( z , { count : 1 } ); }); };
r = function(p, c) { var total = 0; for (var i =0; i < c.length; i++) total += c[i].count; return { count : total }; };
res = db.properties.mapReduce(m,r);
I get the following error:
uncaught exception: assert failed : need to an optionsOrOutString
Any ideas?
If you're using > v1.7.4 then you need to specify the out options:
e.g.
res = db.properties.mapReduce(m,r, {out: "CollectionToOutputResultsTo"});
This will store the results into the named collection. See the output options section of the docs here: http://www.mongodb.org/display/DOCS/MapReduce
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With