时间:2019-05-04 来源:小程序工厂
这样解决了,
const res = await db.collection('user').where({
openid: wxContext.OPENID
}).get();
const arr = res.data;
if (arr.length === 0) {
return db.collection('user').add({
data: {
openid: wxContext.OPENID,
appid: wxContext.APPID,
unionid: wxContext.UNIONID,
},
success(res) {
console.log(res)
}
})
}
async await的方式exports.main = async (event, context) => await db.collection('user') .where({ openid: wxContext.OPENID, // 填入当前用户 openid
}).get()