我在我的沙发数据库上有一个视图,它以这种格式输出数据:
{"rows":[
{"key":["Partner1","Voucher Type 1"],"value":true},
{"key":["Partner1","Voucher Type 2"],"value":true},
{"key":["Partner2","Voucher Type 1"],"value":true},
{"key":["Partner3","Voucher Type 1"],"value":true},
{"key":["Partner4","Voucher Type 1"],"value":true}
]}
我想要做的是有效地“分组”合作伙伴 | 凭证类型,因此在上面的示例中,它将返回类似于:
Partner1: ["Voucher Type 1", "Voucher Type 2"]
Partner2: ["Voucher Type 1"]
Partner3: ["Voucher Type 1"]
Partner4: ["Voucher Type 1"]
目前,我的 map reduce 函数如下所示:
地图:
function(
emit([doc.PartnerName, doc.VoucherType], 1);
}
减少:
function(keys, values) {
return true;
}
我正在查询group=true
我怀疑我需要在 reduce 函数中做更多的事情?