You can take the
{
"lastLogin":{
$gte: ISODate("2022-08-01T00:00:00.000Z"),
$lte: ISODate("2022-08-31T00:00:00.000Z")
}
}
of the find()
query and put that in a $match
stage in your aggregate()
command and then from there do your $lookup
stages.