This is the forth and last post of the serie about the MongoDB Aggregation Framework. We will continue with different queries. By the moment, we are going to use our five documents set inserted in our ‘aggfwktest’ collection. Average computation in a new field
1 2 3 4 5 6 7 |
> db.aggfwktest.aggregate([ ... { $group : { _id : "$user_id", mediascore : { $avg : "$score" } } } ... ]) { "_id" : 3, "mediascore" : 7 } { "_id" : 2, "mediascore" : 6 } { "_id" : 1, "mediascore" : 7.5 } > |
The highest and the lowest, […]