--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
Curious if you could replace the map reduce version with something from the aggregation framework?
On Thursday, August 9, 2012 9:37:33 AM UTC-4, ko wrote:
The post it's a little old, but maybe this will help other persons:
you can with map/reduce using finalize:
db.runCommand({
"mapreduce": "coll",
"map": function() {
emit({id:this.id},{
sell: this.sell,
purchase: this.purchase
});
},
"reduce": function(key,vals) {
return 1;
},
"out": {
inline : 1
},
"finalize": function(key, vals) {
return { amount: vals.sell + vals.purchase};
}
});