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
result
elsif result["result"]
@db[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"]]
end
else
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."