skip to Main Content

MongoDB Join Fields Aggregation

In MongoDB, I have a collection of different movies with their years. Consider these documents: { "_id" : ObjectId("63a994974ac549c5ea982d2b"), "title" : "Destroyer", "year" : 1907 }, { "_id" : ObjectId("63a994974ac549c5ea982d2a"), "title" : "Aquaman", "year" : 1902 }, { "_id" :…

VIEW QUESTION

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",…

VIEW QUESTION
Back To Top
Search