数据库结构如下
_id:xxxxx
member:[
{group:1,id:1},
{group:1,id:2},
{group:1,id:3},
{group:2,id:4},
{group:2,id:4},
{group:3,id:5},
]
想要实现如下的查询结果
_id:xxxxx
member:[
{group:1,id:1,count:3},
{group:1,id:2,count:3},
{group:1,id:3,count:3},
{group:2,id:4,count:2},
{group:2,id:4,count:2},
{group:3,id:5,count:1},
]
多出来的字段count是相同group值的总数.
用聚合输出后更新https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.count.html