I’ve created a projection called MSP which aggregates monthly streams for all users as follows
fromCategory(‘MonthlyStream’)
.foreachStream()
.when(
{
“$init” : function(s,e) { return {count:0, type:{}}},
“$any” : function(s,e) {
s.count += 1;
var key = e.body.Reason;
var val = s.type[key];
s.type[key] = !val ? e.body.Change: val += e.body.Change;
}
})
This creates an aggregated value per monthly stream which I can access using MSP/state?partition=MonthlyStream-MemberId-2015-6
Is there a way for me to aggregate the monthly values into a yearly aggregate across all members? Ideally I’d write something along the lines of
fromCategory(‘MonthlyStream-MemberId’)
.foreachStream()
.when(
{
“$init” : function(s,e) { return {count:0, type:{}}},
“$any” : function(s,e) {
s.count += 1;
var key = e.body.Reason;
var val = s.type[key];
s.type[key] = !val ? e.body.Change: val += e.body.Change;
}
})
But I can’t get a category which groups all monthlystreams per member
Thanks