| Class | Mongo::Operation::Result |
| In: |
lib/mongo/operation/result.rb
lib/mongo/operation/shared/result/aggregatable.rb |
| Parent: | Object |
Result wrapper for operations.
@since 2.0.0
| CURSOR | = | 'cursor'.freeze |
The field name for the cursor document in an aggregation.
@since 2.2.0 |
|
| CURSOR_ID | = | 'id'.freeze |
The cursor id field in the cursor document.
@since 2.2.0 |
|
| FIRST_BATCH | = | 'firstBatch'.freeze |
The field name for the first batch of a cursor.
@since 2.2.0 |
|
| NEXT_BATCH | = | 'nextBatch'.freeze |
The field name for the next batch of a cursor.
@since 2.2.0 |
|
| NAMESPACE | = | 'ns'.freeze |
The namespace field in the cursor
document.
@since 2.2.0 |
|
| N | = | 'n'.freeze |
The number of documents updated in the
write.
@since 2.0.0 |
|
| OK | = | 'ok'.freeze |
The ok status field in the result.
@since 2.0.0 |
|
| RESULT | = | 'result'.freeze |
The result field constant.
@since 2.2.0 |
| replies | [R] | @return [ Array<Protocol::Reply> ] replies The wrapped wire protocol replies. |
Initialize a new result.
@example Instantiate the result.
Result.new(replies)
@param [ Protocol::Reply ] replies The wire protocol replies.
@since 2.0.0
Is the result acknowledged?
@note On MongoDB 2.6 and higher all writes are acknowledged since the
driver uses write commands for all write operations. On 2.4 and lower, the result is acknowledged if the GLE has been executed after the command. If not, no replies will be specified. Reads will always return true here since a replies is always provided.
@return [ true, false ] If the result is acknowledged.
@since 2.0.0
Get the cluster time reported in the server response.
@example Get the cluster time.
result.cluster_time
@return [ BSON::Document ] The cluster time document.
@since 2.5.0
Get the cursor id if the response is acknowledged.
@note Cursor ids of 0 indicate there is no cursor on the server.
@example Get the cursor id.
result.cursor_id
@return [ Integer ] The cursor id.
@since 2.0.0
Get the pretty formatted inspection of the result.
@example Inspect the result.
result.inspect
@return [ String ] The inspection.
@since 2.0.0
Determine if this result is a collection of multiple replies from the server.
@example Is the result for multiple replies?
result.multiple?
@return [ true, false ] If the result is for multiple replies.
@since 2.0.0
Get the namespace of the cursor. The method should be defined in result classes where ‘ns’ is in the server response.
@return [ Nil ]
@since 2.0.0
Check the first document‘s ok field.
@example Check the ok field.
result.ok?
@return [ true, false ] If the command returned ok.
@since 2.1.0
Get the operation time reported in the server response.
@example Get the operation time.
result.operation_time
@return [ Object ] The operation time value.
@since 2.5.0
Get the first reply from the result.
@example Get the first reply.
result.reply
@return [ Protocol::Reply ] The first reply.
@since 2.0.0
If the result was a command then determine if it was considered a success.
@note If the write was unacknowledged, then this will always return
true.
@example Was the command successful?
result.successful?
@return [ true, false ] If the command was successful.
@since 2.0.0
Validate the result by checking for any errors.
@note 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.
@example Validate the result.
result.validate!
@raise [ Error::OperationFailure ] If an error is in the result.
@return [ Result ] The result if verification passed.
@since 2.0.0