heynemann / motorengine

Motorengine is a port of MongoEngine for Tornado.
http://motorengine.readthedocs.org
204 stars 67 forks source link

Implement count aggregation #55

Open heynemann opened 10 years ago

heynemann commented 10 years ago

Implement the count Aggregation as in:

prices=Aggregation.count(Document.price)

This translates to aggregation query:

totalPrice: { $sum: 1 }

The key thing here is that count uses sum to add 1 for each document.

As can be seen in http://docs.mongodb.org/manual/reference/aggregation/group/#pipe._S_group.

This ticket is related to #46.