I am building a view in Couchbase 3.0.1 and would like to reduce multiple values from a map, but I am not sure the right approach.
In the case of an order object, the problem I am trying to solve is that I would like to reduce multiple values from the map (specifically, subtotal, tax and total). I began by outputting the values as an object:
function (doc, meta) {
if (doc.object == "order") {
emit(dateToArray(doc.order_date), {subtotal: doc.subtotal, tax: doc.tax, total: doc.total});
}
}
However, this has not helped me much because I am not sure how to go about reducing the values when the map outputs a custom object. Obviously the built in _sum reduce function won't handle it, so:
Can someone offer some advice on the best way to reduce several values from a map output in Couchbase?