Ada contohnya di seluruh dokumentasi, Google dan situs ini.
Beberapa referensi:
- http://api.mongodb.org/python/current/ contoh/agregasi.html
- http://docs.mongodb.org/manual/reference/aggregation /grup/
- http://docs.mongodb.org/manual/reference/aggregation /sum/
Dan untuk beberapa kode:
self.db.aggregate(
# Lets find our records
{"$match":{"Time":{"$gte":100,"$lte":1000}}},
# Now lets group on the name counting how many grouped documents we have
{"$group":{"_id":"$name", "sum":{"$sum":1}}}
)