Support :db key for :out in map_reduce

References RUBY-389
This commit is contained in:
John Ewart 2011-12-14 17:49:08 -08:00
parent 4858d3030b
commit 28796ac7de
1 changed files with 6 additions and 1 deletions

View File

@ -624,7 +624,12 @@ module Mongo
if raw if raw
result result
elsif result["result"] elsif result["result"]
if result['result'].is_a? BSON::OrderedHash and result['result'].has_key? 'db' and result['result'].has_key? 'collection'
otherdb = @db.connection[result['result']['db']]
otherdb[result['result']['collection']]
else
@db[result["result"]] @db[result["result"]]
end
else else
raise ArgumentError, "Could not instantiate collection from result. If you specified " + raise ArgumentError, "Could not instantiate collection from result. If you specified " +
"{:out => {:inline => true}}, then you must also specify :raw => true to get the results." "{:out => {:inline => true}}, then you must also specify :raw => true to get the results."