I have collections that have dates in an array like:
datesArray: [{
start_date: Date,
end_date: Date
}]
I want only those collections which satisfy all elements of datesArray.
I am using it in aggregation $match operator like:
Model.aggregate([
{
$match: {
'datesArray.start_date': { $gte: new Date('11-01-21') },
'datesArray.end_date': { $lte: new Date('11-30-21') }
}
}
])
I tried with $elemMatch but it matches at least one array element. I also tried $all with $elemMatch but had no success.
Thank you