Tutorials Exercises Get Certified Services Menu
Log in
Sign Up Spaces Bootcamps

MongoDB Aggregation $group

Aggregation $group

This aggregation stage groups documents by the unique _id expression provided.

Don't confuse this _id expression with the _id ObjectId provided to each document.


In this example, we are using the "sample_airbnb" database loaded from our sample data in the Intro to Aggregations section.

    [ { $group : { _id : "$property_type" } } ]
Try it Yourself »

This will return the distinct values from the property_type field.