云函数如何根据用户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,
}
}
1 回复
这时候都没有人 = =看,只有自己先找一找https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/document/Document.get.html
相关的内容,doc 的id