MapReduce aggregation based on attributes contained outside of document?

I did this by wrapping the MapReduce in some stored javascript.

I did this by wrapping the MapReduce in some stored javascript. Function (query) { var one = db.people. FindOne(query); var activity_ids = ; for (var k in one.

Activities){ activity_ids. Push(parseInt(k)); } var activity_location_map = {}; db.activities. Find({id : {$in : activity_ids}}).

ForEach(function(a){ activity_location_mapa. Id = a. Location; }); return db.people.

MapReduce( function map(){ for (var k in this. Activities){ emit({location : activity_location_mapk} , { total: this. Activitiesk }); emit({location: activity_location_mapk} , { total: this.

Activitiesk }); } }, function reduce(key, values){ var reduced = {total: 0}; values. ForEach(function(value){ reduced. Total += value.

Total; }); return reduced; }, {out : {inline: true}, scope : { activity_location_map : activity_location_map }} ). Results; } Annoying, and messy, but it works, and I can't think of owt better.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions