dirn/Simon

Add support for aggregation

Opened this issue · 0 comments

dirn commented

PyMongo includes an aggregate() method that allows for the following:

>>> from bson.son import SON
>>> db.things.aggregate([
...         {"$unwind": "$tags"},
...         {"$group": {"_id": "$tags", "count": {"$sum": 1}}},
...         {"$sort": SON([("count", -1), ("_id", -1)])}
...     ])
...
{u'ok': 1.0, u'result': [{u'count': 3, u'_id': u'cat'}, {u'count': 2, u'_id': u'dog'}, {u'count': 1, u'_id': u'mouse'}]}

I'd like to make this a bit more pythonic.

I've typed a couple of beginning thoughts, but keep changing them, so I'm going to remove them entirely for now.