I would like to aggregate $match on the data inside the array object:
{ example: [{target: "1"}] }
I have tried $match, $elemMatch, $arrayEleAt but I dont know how to write the correct syntax.
{ $lookup: { from: "example", localField: "user_id", foreignField: "user_id", as: "example" } },
{
$match: {
"start_date": { $gte: new Date(startDate) },
"end_date": { $lte: new Date(endDate) },
"type": Type,
"target": "1"
},
},
{ $sort: { startDate: 1 } },