【发布时间】:2021-06-19 06:07:39
【问题描述】:
我是 mongoose 和 mongoDB 的新手,我有以下查询,运行时会引发以下错误。如果有人可以帮助我处理问题并且仍然获得相同的输出,那就太好了
//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 } }
]
}
},
]))
【问题讨论】:
标签: javascript node.js mongodb mongoose mongodb-query