I am trying to make a aggregate pipeline - $lookup to receive from another
collection only items that are not equal to specific _id
for example :
ClinicsCollection :
{_id:1,name:'some name1'}
{_id:2,name:'some name2'}
{_id:3,name:'some name3'}
BusinessCollection :
{_id:1,name:"some business name",clinics:[1,2,3]}
My aggregate pipeline query :
db.business.aggregate([
{$match: {_id: mongoose.Types.ObjectId(businessId)}},
{$lookup:
{from: "ClinicsCollection", localField: "clinics", foreignField: "_id", as: "clinics"}},
]
I want to filter all clinics that are not equal to specific id number let say _id : 1
expected result :
clinics :[
{_id:2,name:'some name2'}
{_id:3,name:'some name3'}
]
How can i achieve that ?
Thanks