单独本地调试或云端调试时,都能看到查询到的数据结果,程序调用,结果就为空。百思不解,希望高手指点一二,十分感谢!
云函数:
// 云函数入口函数
exports.main = async(event, context) => {
console.log(event)
return await db.collection(event.db1).aggregate().lookup({
from: event.db2,
localField: event.localField,
foreignField: event.foreignField,
as: 'dataList',
})
.end()
.then(res => console.log(res))
.catch(err => console.log(err))
}
调用云函数代码:
getQuesAndAnswer: function() {
console.log('lookup startes')
wx.cloud.callFunction({
name: 'lookupDB',
data: {
db1: 'questions',
db2: 'ques_answer',
localField: '_id',
foreignField: 'question_id',
},
success: function (res) {
console.log('lookup result: ', res)
},
fail: function(err)
{
console.log(err)
}
})
},