云函数在本地调试可以获取到数据库数据,但是上传之后获取数据为空

发布于 8 年前作者 limin12866 次浏览最后编辑 8 年前来自 ask
  • 当前 Bug 的表现(可附上截图)

  • 预期表现
WXOPEN Club 内容图片
  • 复现路径

  • 提供一个最简复现 Demo

const cloud = require('wx-server-sdk')

cloud.init()

const db = cloud.database()

const MAX_LIMIT = 100

exports.main = async (event, context) => {

// 先取出集合记录总数

const countResult = await db.collection('company').where(event).count()

const total = countResult.total

// 计算需分几次取

const batchTimes = Math.ceil(total / 100)

// 承载所有读操作的 promise 的数组

const tasks = []


const list = await db.collection('company').where(event).get()

console.log("list:",list)

return list

}



1 回复
sxu
sxu1 楼6 年前

请确认下小程序端调用的环境是不是环境 shouer 的 getlist 函数呢?可以通过 Network 面板看

https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/debug.html