| Class | Mongo::Collection::View::MapReduce |
| In: |
lib/mongo/collection/view/map_reduce.rb
|
| Parent: | Object |
Provides behavior around a map/reduce operation on the collection view.
@since 2.0.0
| INLINE | = | 'inline'.freeze |
The inline option.
@since 2.1.0 |
|
| REROUTE | = | 'Rerouting the MapReduce operation to the primary server.'.freeze |
Reroute message.
@since 2.1.0 |
| map_function | [R] | @return [ String ] map The map function. |
| reduce_function | [R] | @return [ String ] reduce The reduce function. |
| view | [R] | @return [ View ] view The collection view. |
Initialize the map/reduce for the provided collection view, functions and options.
@example Create the new map/reduce view.
@param [ Collection::View ] view The collection view. @param [ String ] map The map function. @param [ String ] reduce The reduce function. @param [ Hash ] options The map/reduce options.
@since 2.0.0
Iterate through documents returned by the map/reduce.
@example Iterate through the result of the map/reduce.
map_reduce.each do |document|
p document
end
@return [ Enumerator ] The enumerator.
@since 2.0.0
@yieldparam [ Hash ] Each matching document.
Execute the map reduce, without doing a fetch query to retrieve the results
if outputted to a collection.
@example Execute the map reduce and get the raw result.
map_reduce.execute
@return [ Mongo::Operation::Result ] The raw map reduce result
@since 2.5.0
Set or get the output location for the operation.
@example Set the output to inline.
map_reduce.out(inline: 1)
@example Set the output collection to merge.
map_reduce.out(merge: 'users')
@example Set the output collection to replace.
map_reduce.out(replace: 'users')
@example Set the output collection to reduce.
map_reduce.out(reduce: 'users')
@param [ Hash ] location The output location details.
@return [ MapReduce, Hash ] The new MapReduce operation or the value
of the output location.
@since 2.0.0
Whether to include the timing information in the result.
@example Set the verbose value.
map_reduce.verbose(false)
@param [ true, false ] value Whether to include timing information
in the result.
@return [ MapReduce, Hash ] The new MapReduce operation or the value
of the verbose option.
@since 2.0.5