{ "userID" : 1, "amount" : 2, "date" : ISODate("2012-04-03T20:53:19.490Z") }
{ "userID" : 1, "amount" : 4, "date" : ISODate("2012-04-03T20:53:19.490Z") }
{ "userID" : 2, "amount" : 4, "date" : ISODate("2012-04-03T20:53:19.490Z") }
{ "userID" : 3, "amount" : 1, "date" : ISODate("2012-04-03T20:53:19.490Z") }
{ "userID" : 1, "amount" : 2, "date" : ISODate("2012-04-03T20:53:19.490Z") }
I'm performing incremental Map/Reduce operation where when I'm counting the sum of purchases. The m/r functions are very simple so I'm not writing it here.
MapReduceCommand cmd = new MapReduceCommand(coll, map, reduce, "result", MapReduceCommand.OutputType.MERGE, null);
The result will be the following. Which is perfect:
{ "_id" : 1, "value" : 8 }
{ "_id" : 2, "value" : 4 }
{ "_id" : 3, "value" : 1 }
If user with userIF 4 will be added to system,my incremental map reduce would take care of it and new row will be added to result collection.
Problem: if userID 2 will be deleted from system, his row would still remain in result collection. How can I take care of such stale values when using incremental Map reduce?