MongoDB Documentation, Release 3.0.4 – Suppresses the id from the results. The aggregate() method includes the _id , unless explicitly suppressed. • The $month operator converts the values of the joined field to integer representations of the month. Then the $project operator assigns those values to the month_joined field. • The $sort operator sorts the results by the month_joined field. The operation returns results that resemble the following: The following operation shows how many people joined each month of the year. You might use this aggregated data for recruiting and marketing strategies. The pipeline passes all documents in the users collection through the following operations: The result of this aggregation operation would resemble the following: • The $month operator converts the values of the joined field to integer representations of the month. Then the $project operator assigns the values to the month_joined field. • The $project operator creates a new field called month_joined . • The $group operator collects all documents with a given month_joined value and counts how many docu- ments there are for that value. Specifically, for each unique value, $group creates a new “per-month” document with two fields: – _id , which contains a nested document with the month_joined field and its value. – number , which is a generated field. The $sum operator increments this field by 1 for every document containing the given month_joined value. • The $sort operator sorts the documents created by $group according to the contents of the month_joined field. Chapter 7. Aggregation 458 db.users.aggregate( [ { $project : { month_joined : { $month : "$joined" } } } , { $group : { _id : {month_joined:"$month_joined"} , number : { $sum : 1 } } }, { $sort : { "_id.month_joined" : 1 } } ] ) { "month_joined" : 1, "name" : "ruth" }, { "month_joined" : 1, "name" : "harold" }, { "month_joined" : 1, "name" : "kate" } { "month_joined" : 2, "name" : "jill" } Return Total Number of Joins per Month