I have one collection of documents that are formatted as follows:
{
_id: ObjectId('617d318eb863ee273c66b111'),
my_object: {
_id: ObjectId('617d318eb863ee273c66b222')
//other fields
},
exclusion_object: {
my_arr: ObjectId('617d318eb863ee273c66b222')
//other fields
}
}
So I need to exclude the documents where my_object._id is included in exclusion_object.my_arr
I tried (in $match stage):
{
$match:{
'exclusion_object.my_arr': { $nin:['my_object._id','$exclusion_object.my_arr']}
}
}
This doesn't seem to work.. any suggestion?