I have two collections projects
and products
, where products
has a field project
, which refers to the projects._id
field.
I am using this aggregation $lookup to find the products that belong to a specific project
{
from: 'products',
let: { id: '$_id'},
pipeline: [{
$match: { project: '$$id' }
}],
as: 'products'
}
the resulting products field is always empty, and I don’t understand why.
(I know I can use the other $lookup variant with foreignField localField, but I think I need the pipeline because I want to add more clauses to the $match)