- 请教一下,云数据库可以一次返回sum和count吗?
const _ = db.command; const $ = _.aggregate; const res = await commentCollection .aggregate() .unwind('$commentArray') .match({ diner_id: event.x_id,}) // .count('commentArray') .group({ _id: null, totalCommentScore: $.sum('$commentArray.commentScore'), avgCommentScore: $.avg('$commentArray.commentScore'), }) .end() 以上是我查询一个集合的方法,单独执行group获取sum和avg,或者count(被注释的部分),都是可以正确执行的。 但是不知道如何同时获取commentArray数组中对commentScore(number类型)的sum、count,请大家指导一下,谢谢。
2020-03-18 - 云数据库可以检索非根节点吗?
请教一下,云数据库能搜索非根节点的数据吗?比如我的一个集合actionInfo的一条数据是这样的: index:1, user-name:'xx' action-date:[ 03-13, 03-14, 03-15 ], 我可以直接用云数据库来查action-date的总数吗?
2020-03-15