mongoid/mongoid — pull request #3197 by wpiekutowski (2013-07-31 18:53:35+00:00)
Title: Improve Mongoid::Contextual::Aggregable::Mongo#aggregates

1. Stop Mongoid::Contextual::Aggregable::Mongo#aggregates from checking if collection is empty. It was required when map/reduce was used, but not anymore with Aggregation Framework.

2. Make Mongoid::Contextual::Aggregable::Mongo#aggregates return a better hash

Hash has count set to a number of documents with the provided field. When
there're no documents with that field, then count is 0 and other keys are set to
nil.

Previous behavior was inconsistent:
- when there were any documents with the requested field, count was set to a
number of documents with that field
- otherwise, count was set to a number of documents matching the query,
but not to a numer of documents with the requested field, which was 0

Makes Mongoid::Contextual::Aggregable::Memory behave in a similar way.