Here's what it looks like so far:
collection.aggregate(
[
{
$match: {
ct: {$gte: dateFrom, $lt: dateTo },
}
},
{
$group: {
_id: '$user'
}
}
]
).toArray((err, result) => {
callback(err, result.length)
});
This gets me a list of users like this which I can count for DAU/MAU:
But I think this is not efficient, what's the correct way of doing this?