Method: Mongoid::Contexts::Enumerable#aggregate

Defined in:
lib/mongoid/contexts/enumerable.rb

#aggregateObject

Return aggregation counts of the grouped documents. This will count by the first field provided in the fields array.

Returns:

A Hash with field values as keys, count as values



17
18
19
20
21
# File 'lib/mongoid/contexts/enumerable.rb', line 17

def aggregate
  counts = {}
  group.each_pair { |key, value| counts[key] = value.size }
  counts
end