lookup的pipeline不能正常工作
发布于 5 年前 作者 wanggang 8467 次浏览 来自 官方Issues

https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.lookup.html


描述:在数据库里执行“高级操作”,里面想测试lookup语句,按照示例写了pipeline语句,但是执行失败,报错显示$.pipeline() 的写法是错误的,不知道该怎么修正

db.collection('schedule')

.aggregate()

.lookup({

from:'teacher',

localField: 'teacher',

foreignField: '_id',

as: 'teacherList',

})

.lookup({

from: 'class',

let: {

schedule_teacher: '$teacher',

schedule_monday: '$monday',

},

pipeline: $.pipeline()

.match(

_.expr($.and([

$.eq(['$teacher', '$$schedule_teacher']),

$.eq(['$monday', '$$schedule_monday'])

]))

)

.project({

_id: 0

})

.done(),

as: 'classList',

})

.end()

RuntimeError: cannot read property ‘pipeline’ (from line 16, col 17 to line 16, col 25) 14 | schedule_monday: ‘$monday’, 15 | }, > 16 | pipeline: $.pipeline() | ^^^^^^^^ 17 | .match( 18 | _.expr($.and([ 19 | $.eq([’$teacher’, ‘$$schedule_teacher’]),

1 回复

云函数运行正常,看了其他帖子,应该是数据库的“高级操作”还不支持lookup的pipeline方式

回到顶部