Hi David,
You’ll need a map function:
function(o) {
emit(‘basePoints’, o.basePoints);
emit(‘bonusPoints’, o.bonusPoints);
}
A reduce function:
_sum
And you’ll have to call your view with:
?group=true
Regards,
Aurélien
> Le 13 juin 2018 à 19:13, David Park <[email protected]> a écrit :
>
> Say I have a map that emits the following object:
>
>>>> {"basePoints": 2000, "bonusPoints": 1000}
>>>> {"basePoints": 1000, "bonusPoints": 50}
>>>> {"basePoints": 10000, "bonusPoints": 5000}
>
> How could I write a reduce in Erlang that would return an aggregate object
> like this:
>
>>>> {"basePoints": 13000, "bonusPoints": 6050}
>
> (I would rather not have to write 2 separate views that emit each value
> separately if i can help it)
>
> Thanks!
>
> David Park Software Developer