I have a hard time believing this question hasn\'t been asked and answered somewhere already, but I can\'t find any trace of it.
I have a MongoDB aggregation query t
My answer is:
{$match:{
$and:[{
name:{
$exists:true
}
}, {
$expr:{
$eq:["$$id", "$_id"]
}
}]
}}
I use this in lookup, on my pipeline stage. This post 2 rules the first one, name must exist. And the second thing is the relation between these 2 collection. I Am sure u can modify this for your question.