云函数中怎么获取collection.count的结果?
发布于 6 年前 作者 jun86 615 次浏览 来自 问答

现在的代码是这样:

db.collection(‘join’).where({

_openid: openId,

is_reply: true,

is_agree: true,

is_opinion: false

}).count().then(function(res) {

console.log(‘result’)

console.log(res.total)

})

但是发现根本不会进入then()内部

正确的写法应该是什么?

1 回复
exports.main = async(event, context) => {
 
 
   const count =await  countdb.collection('join').where({
 
  _openid: openId,
 
  is_reply: true,
 
  is_agree: true,
 
  is_opinion: false
 
  }).count();
 
  return   {total: count.total}
}

回到顶部