云函数如何根据用户openid 获取云数据库的自身数据?wxContext.OPENID怎么不能赋值
[图片] const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const MAX_LIMIT = 100
//.doc(this.data.id_)
exports.main = async(event, context) => {
const wxContext = cloud.getWXContext()
return await db.collection("userlist").where({
_id: wxContext.OPENID
}).orderBy('time', 'desc').get({
success: function(res) {
// return res
}
});
return {
// data,
event,
openid: wxContext.OPENID,
appid: wxContext.APPID,
unionid: wxContext.UNIONID,
}
}