Hello,
I am trying to filter Albums object in the last project stage of aggregation as the below
{
$project: {
Artist: 1,
Albums: {
$filter:{
input : "$Albums",
as : "album",
cond : {
$in: [{"$ifNull":[{$first: "$$album.Sales.Total_Sales.Date"},-1]},dateArray]
}
}
}
}
}
The weird thing here is I try to use the array index first instead of $first operator like below
$in: [{"$ifNull":["$$album.Sales.Total_Sales.0.Date",-1]},dateArray]
or
$in: ["$$album.Sales.Total_Sales.0.Date",dateArray]
and it doesn’t work like that . I have to specifically use the $first operator instead of array index. What am I missing here? Is there any documentation for this behaviour?