下面的程序是在云函数里的例子,我在小程序里参考这个例子求得的total的值是undefined为何?

发布于 9 年前作者 qiangyi9881 次浏览最后编辑 9 年前来自 issues
const cloud = require('wx-server-sdk')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})
const db = cloud.database()
const MAX_LIMIT = 100
exports.main = async (event, context) => {
  // 先取出集合记录总数
  const countResult = await db.collection('todos').count()
  const total = countResult.total
  // 计算需分几次取
  const batchTimes = Math.ceil(total / 100)

3 回复
duanjing
duanjing1 楼6 年前

云函数只有一半?

wei01
wei012 楼6 年前

Collection.count(): Promise<Object>

支持端:小程序 , 云函数

统计匹配查询条件的记录的条数

这个方法的官方解释是这样的。匹配查询 条件的记录。

不知道是不是这个原因,因为你没有加条件。

houyan
houyan3 楼6 年前

集合的权限是什么呢