I try to get back from the array weekPlan only the elements that are between the two dates. However, I get either no result at all or all results unfiltered where it is clear that the date is not in the range.
The explicit $and is not required. The following $match will return the same documents.
$match: { "type.date" : { $gt: 0 ,$lt: 3 } }
But I think the use-case is about only returning the matching element in the array for matching documents. I think that for this you need a $filter in a $project stage.
The $unwind version is also promising since an $unwind and $match is almost like a $filter.
Ha, that’s something I’ve done forever, thanks for that reply! Probably as at some point in the past I added two filters against the same field and spend ages working out why only one of the conditions was picking up!
Shall be making use of that!