MongoDB Documentation, Release 3.0.4 The following operation returns user names in upper case and in alphabetical order. The aggregation includes user names for all documents in the users collection. You might do this to normalize user names for processing. All documents from the users collection pass through the pipeline, which consists of the following operations: The results of the aggregation would resemble the following: The following aggregation operation returns user names sorted by the month they joined. This kind of aggregation could help generate membership renewal notices. The pipeline passes all documents in the users collection through the following operations: • The $project operator: – Creates two new fields: month_joined and name . • The $project operator: – creates a new field called name . – converts the value of the _id to upper case, with the $toUpper operator. Then the $project creates a new field, named name to hold this value. – suppresses the id field. $project will pass the _id field by default, unless explicitly suppressed. • The $sort operator orders the results by the name field. Return Usernames Ordered by Join Month Normalize and Sort Documents 457 7.3. Aggregation Examples db.users.aggregate( [ { $project : { month_joined : { $month : "$joined" }, name : "$_id", _id : 0 } }, { $sort : { month_joined : 1 } } ] ) { "name" : "JANE" }, { "name" : "JILL" }, { "name" : "JOE" } db.users.aggregate( [ { $project : { name:{$toUpper:"$_id"} , _id:0 } }, { $sort : { name : 1 } } ] )