云函数无法提取到数据库内容?
const cloud = require(‘wx-server-sdk’)
cloud.init()
const db = cloud.database()
var OutPut={}
var total=0
exports.main = async (event, context) => {
return new Promise((resolve, reject) => {
const countResult = await db.collection('todo').count()
total = countResult.total
OutPut = { total: total }
resolve(OutPut)
})
}
但输出的total仍然是0。实际上数据库是有内容的。