lib/mongoid/contextual/map_reduce.rb in mongoid-3.0.1 vs lib/mongoid/contextual/map_reduce.rb in mongoid-3.0.2
- old
+ new
@@ -76,13 +76,13 @@
# @param [ Criteria ] criteria The Mongoid criteria.
# @param [ String ] map The map js function.
# @param [ String ] reduce The reduce js function.
#
# @since 3.0.0
- def initialize(criteria, map, reduce)
- @criteria = criteria
- command[:mapreduce] = criteria.klass.collection_name.to_s
+ def initialize(collection, criteria, map, reduce)
+ @collection, @criteria = collection, criteria
+ command[:mapreduce] = collection.name.to_s
command[:map], command[:reduce] = map, reduce
apply_criteria_options
end
# Get the number of documents that were input into the map/reduce.
@@ -264,10 +264,10 @@
# @return [ Hash ] The results of the command.
#
# @since 3.0.0
def results
raise Errors::NoMapReduceOutput.new(command) unless command[:out]
- @results ||= session.command(command)
+ @results ||= session.with(consistency: :strong).command(command)
end
end
end
end