Class: Mongo::Operation::Commands::MapReduce::Result
- Defined in:
- lib/mongo/operation/commands/map_reduce/result.rb
Overview
Defines custom behaviour of results for a map reduce operation.
Constant Summary collapse
- COUNTS =
The counts field for the map/reduce.
'counts'.freeze
- RESULTS =
The field name for a result without a cursor.
'results'.freeze
- TIME =
The time the operation took constant.
'timeMillis'.freeze
Constants inherited from Result
Result::CURSOR, Result::CURSOR_ID, Result::FIRST_BATCH, Result::N, Result::NAMESPACE, Result::NEXT_BATCH, Result::OK, Result::RESULT
Instance Attribute Summary
Attributes inherited from Result
Instance Method Summary collapse
-
#counts ⇒ Hash
Gets the map/reduce counts from the reply.
-
#documents ⇒ Array<BSON::Document>
Get the documents from the map/reduce.
-
#successful? ⇒ true, false
If the result was a command then determine if it was considered a success.
-
#time ⇒ Integer
Get the execution time of the map/reduce.
-
#validate! ⇒ Result
Validate the result by checking for any errors.
Methods inherited from Result
#acknowledged?, #cursor_id, #each, #initialize, #inspect, #multiple?, #namespace, #ok?, #reply, #returned_count, #written_count
Constructor Details
This class inherits a constructor from Mongo::Operation::Result
Instance Method Details
#counts ⇒ Hash
Gets the map/reduce counts from the reply.
48 49 50 |
# File 'lib/mongo/operation/commands/map_reduce/result.rb', line 48 def counts reply.documents[0][COUNTS] end |
#documents ⇒ Array<BSON::Document>
Get the documents from the map/reduce.
60 61 62 |
# File 'lib/mongo/operation/commands/map_reduce/result.rb', line 60 def documents reply.documents[0][RESULTS] || reply.documents[0][RESULT] end |
#successful? ⇒ true, false
If the write was unacknowledged, then this will always return true.
If the result was a command then determine if it was considered a success.
76 77 78 |
# File 'lib/mongo/operation/commands/map_reduce/result.rb', line 76 def successful? !documents.nil? end |
#time ⇒ Integer
Get the execution time of the map/reduce.
88 89 90 |
# File 'lib/mongo/operation/commands/map_reduce/result.rb', line 88 def time reply.documents[0][TIME] end |
#validate! ⇒ Result
This only checks for errors with writes since authentication is handled at the connection level and any authentication errors would be raised there, before a Result is ever created.
Validate the result by checking for any errors.
106 107 108 |
# File 'lib/mongo/operation/commands/map_reduce/result.rb', line 106 def validate! documents.nil? ? raise(Error::OperationFailure.new(parser.)) : self end |