Top "Aggregation-framework" questions

The MongoDB Aggregation Framework provides a means to reshape and aggregate data in MongoDB 2.2+.

mongo group and count with condition

I'm trying to group a set of documents and count them based on their value. For example { "_id" : 1, "item" : "abc1", "…

mongodb mongodb-query aggregation-framework nosql
How to use a for loop in the mongodb shell?

How can i use a for loop in the mongo db shell? My attemps are stucking at this point: for (…

mongodb mongodb-query aggregation-framework mongo-shell mongodb-aggregation
how to $project ObjectId to string value in mongodb aggregate?

Is there an operator I could use in aggregate function to get a string instead of ObjectId in response? db.…

mongodb mongodb-query aggregation-framework
Mongodb Aggregation Framework | Group over multiple values?

I would like to use mongoDB's Aggregation Framework to run what in SQL would look a bit like: SELECT SUM(…

mongodb aggregation-framework
How to use MongoDBs aggregate `$lookup` as `findOne()`

So as you all know, find() returns an array of results, with findOne() returning just a simply object. With Angular, …

mongodb mongodb-query aggregation-framework
Group result by 15 minutes time interval in MongoDb

I have a "status" collection like this strcture - { _id: ObjectId("545a0b63b03dbcd1238b4567"), status: 1004, comment: "Rem dolor …

mongodb mongodb-query aggregation-framework
Mongodb sort inner array

I've been looking for a while now and can't seem to sort an inner array and keep that in the …

mongodb aggregation-framework
Check if every element in array matches condition

I have a collection of documents: date: Date users: [ { user: 1, group: 1 } { user: 5, group: 2 } ] date: Date users: [ { user: 1, group: 1 } { user: 3, group: 2 } ] …

mongodb mapreduce mongodb-query aggregation-framework
MongoDB concatenate strings from two fields into a third field

How do I concatenate values from two string fields and put it into a third one? I've tried this: db.…

mongodb mongodb-query aggregation-framework string-concatenation mongodb-update
how to group in mongoDB and return all fields in result

I am using aggregate method in mongoDB to group but when I use $group it returns the only field which …

node.js mongodb mongoose aggregation-framework