问题是我通过主表聚合查询附表时,按照官方例子的写法,直接抛错
错误提示
errCode: DATABASE_REQUEST_FAILED | errMsg: [FailedOperation] (FailedToParse) $lookup argument 'left: { aaa: "$_id" }' must be a string, is type object
错误代码
const collection = db.collection('mfs-qa-question')
const res = await collection.aggregate()
.lookup({
from: 'mfs-qa-answer',
left: {
question_id: '$_id'
},
pipeline: $.pipeline()
.match(dbCmd.expr($.eq(['$question_id', '$$question_id'])))
.done(),
as: 'answerList'
})
.end()
通过主表的聚合查询附表的副本question_id === 主表_id的数据
用的是腾讯云服务,
1 个回复
DCloud_uniCloud_WYQ
那是let不是left