I'm new to mongoose & mongoDB, I have following query, which when run throws the follow error. It would be great if some can help me handle the issue and still get the same output
//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 } }
]
}
},
]))