My records like this [{ createdAt }, {createdAt}, {createdAt} ]
I need average records per month.
january => 3 records
february => 2 records etc..
My records like this [{ createdAt }, {createdAt}, {createdAt} ]
I need average records per month.
january => 3 records
february => 2 records etc..
2
Answers
You can try to
$group
by month and year when counting and by month when averaging:Link to playground
Not fully clear what you mean by "average records per month" but I think it would be this:
Getting the month name is not so easy, either you use a external library or build your own with $switch