Module: Mongoid::MapReduce::ClassMethods
- Defined in:
- lib/mongoid/mapreduce/base.rb
Instance Method Summary collapse
-
#map_reduce(map_key = :_id, options = {}, &block) ⇒ Object
Run a map/reduce operation on the current model.
Instance Method Details
#map_reduce(map_key = :_id, options = {}, &block) ⇒ Object
Run a map/reduce operation on the current model
map_key: Symbol or String, the field used in the map function
Returns a Hash of results
13 14 15 16 17 18 |
# File 'lib/mongoid/mapreduce/base.rb', line 13 def map_reduce(map_key=:_id, ={}, &block) [:map_key] = map_key reducer = Reducer.new(self, criteria.selector, ) reducer.instance_eval(&block) if block.present? reducer.run end |