我是mongoose&mongoDB的新手,我有following查询,当运行时会抛出follower错误。如果有人能帮我处理这个问题,并且仍然得到相同的输出,那就太好了
//interview.model.js => mongodb show name as interview
module.exports = mongoose.model('Interview', interviewSchema);
//candidate.model.js => mongodb show name as candidate
module.exports = mongoose.model('Candidate', candidateSchema);
const [result, err] = await of(Interview.aggregate([
{
$match: {
...filterQuery,
}
},
{
$lookup: {
'from': 'candidates',
'localField': 'candidateId',
'foreignField': '_id',
'as': 'candidateId',
pipeline: [
{ $match: { 'candidateId.interviewCount': 0 }},
{ $project: { firstName:1, status:1, avatar:1 } }
]
}
},
]))
0
如果管道位于$lookup内部,则不能使用localField或foreignfield。有关语法和示例,请参阅MongoDB文档...