描述:在数据库里执行“高级操作”,里面想测试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’]),