云开发(学习笔记)聚合分组查询group()

发布于 5 年前作者 jintao847 次浏览最后编辑 5 年前来自 share

按商品分类展示商品

return dbRes.match({
        shopID: event.shopId
      })
      .group({
        _id: {
          sortName: '$sortItem.sortName'
        },
        list: $.push({
          _id: '$_id',
          goodsName: '$goodsName',
          goodsDesc: '$goodsDesc',
          goodsPrice: '$goodsPrice',
          imgUrl: '$imgUrl'
        })
      })
      .end().then(res => {
        console.log(res);
        return res
      })
0 回复
暂无回复