Mongo lookup with condition

Solution:

You can use the pipeline option to achieve this. However you will need to read the document of the extension which is you used. But as mongoshell you can do as follow

{
   $lookup:
     {
       from: <collection to join>,
       let: { <var_1>: <expression>, …, <var_n>: <expression> },
       pipeline: [ <pipeline to execute on the collection to join> ],
       as: <output array field>
     }
}

And specify condition inside pipeline. Read from the following link. https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/#join-conditions-and-uncorrelated-sub-queries