0

I'm using the latest version of mongoose. My model looks like this:
{ id:'', name:'', text:'', createdAt:Date }

Now I'd like to create a query that is giving me a [minute] rollup.

For instance let's say I have 3 entries in my collection. a) createdAt: 12:50
b) createdAt: 12:50
c) createdAt: 12:51

If I want to have minute rollups, I would want to have a result like this: { 12:50: 2, 12:51: 1 }

I've tried a few different aggregations, but none of them really worked.

Christian
  • 6,961
  • 10
  • 54
  • 82
  • 2
    Try `db.col.aggregate( [ {$group: { _id :{$minute:"$createdAt"}, count:{$sum: 1 } } } ])` – s7vr Feb 22 '18 at 13:06
  • Yes, look at the other [answer](https://stackoverflow.com/a/27366497/2683814) which does something similar for month. Also, I have noted solution applicable for your case in my previous comment. – s7vr Feb 22 '18 at 13:32

0 Answers0