云开发 json 数据库聚合如何返回结果?,急
发布于 5 年前 作者 na03 2920 次浏览 来自 官方Issues


const $ = db.command.aggregate

db.collection('goods')  .aggregate()  .group({    _id: null,    totalPrice: $.sum('$price')  })

 .end()

上面是文档中的示例,介绍说返回的是{ "_id": null, "totalPrice": 111 }

何把返回结果取出来,比如用到

this.setData({

})

里面,谢谢

1 回复

用 await 来执行获取结果,或者用 then 在回调中获取。再参考下文档,理解下 promise。

回到顶部