Mongodb – How to accumulate category counted fixed-size array in `$group` stage?
Let books collection be, db.books.insertMany([ { "name": "foo", "category": 0, publishedAt: ISODate("2008-09-14T00:00:00Z") }, { "name": "bar", "category": 1, publishedAt: ISODate("1945-08-17T00:00:00Z") }, { "name": "baz", "category": 1, publishedAt: ISODate("2002-03-01T00:00:00Z") }, { "name": "qux", "category": 2, publishedAt: ISODate("2002-01-21T00:00:00Z") }, { "name": "quux",…