Class: Mongo::Operation::Update::Result
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::Mongo::Operation::Result ,
Forwardable
|
|
Instance Chain:
self,
::Mongo::Operation::Result ,
Enumerable
|
|
Inherits: |
Mongo::Operation::Result
|
Defined in: | lib/mongo/operation/update/result.rb |
Overview
Defines custom behavior of results for an update.
Constant Summary
-
MODIFIED =
Internal use only
The number of modified docs field in the result.
'nModified'.freeze
-
UPSERTED =
Internal use only
The upserted docs field in the result.
'upserted'.freeze
::Mongo::Operation::Result
- Inherited
CURSOR, CURSOR_ID, FIRST_BATCH, N, NAMESPACE, NEXT_BATCH, OK, RESULT
Class Method Summary
::Mongo::Operation::Result
- Inherited
.new | Initialize a new result. |
Instance Attribute Summary
- #upsert? ⇒ Boolean readonly private
::Mongo::Operation::Result
- Inherited
#acknowledged? | Is the result acknowledged? |
#connection, #connection_description, #connection_global_id, #context, | |
#has_cursor_id? | Whether the result contains cursor_id. |
#ok? | Check the first document’s ok field. |
#replies, | |
#successful? | If the result was a command then determine if it was considered a success. |
#write_concern_error? | Whether the operation failed with a write concern error. |
#query_failure? |
Instance Method Summary
- #bulk_result
-
#matched_count ⇒ Integer
Get the number of documents matched.
-
#modified_count ⇒ Integer
Get the number of documents modified.
-
#upserted_count ⇒ Integer
Returns the number of documents upserted.
-
#upserted_id ⇒ Object
The identifier of the inserted document if an upsert.
::Mongo::Operation::Result
- Inherited
#cluster_time | Get the cluster time reported in the server response. |
#cursor_id | Get the cursor id if the response is acknowledged. |
#documents | Get the documents in the result. |
#each | Iterate over the documents in the replies. |
#error | The exception instance (of Error::OperationFailure::Family) that would be raised during processing of this result. |
#inspect | Get the pretty formatted inspection of the result. |
#labels | Gets the set of error labels associated with the result. |
#n | Alias for Result#written_count. |
#namespace | Get the namespace of the cursor. |
#operation_time | Get the operation time reported in the server response. |
#reply | Get the reply from the result. |
#returned_count | Get the number of documents returned by the server in this batch. |
#snapshot_timestamp, #topology_version, | |
#validate! | Validate the result by checking for any errors. |
#written_count | Get the number of documents written by the server. |
#aggregate_returned_count, #aggregate_written_count, #first_document, #operation_failure_class, #parser, | |
#raise_operation_failure | Raises a Mongo::OperationFailure exception corresponding to the error information in this result. |
Instance Attribute Details
#upsert? ⇒ Boolean
(readonly, private)
# File 'lib/mongo/operation/update/result.rb', line 107
def upsert? first[UPSERTED] end
Instance Method Details
#bulk_result
# File 'lib/mongo/operation/update/result.rb', line 101
def bulk_result BulkResult.new(@replies, connection_description) end
#matched_count ⇒ Integer
Get the number of documents matched.
# File 'lib/mongo/operation/update/result.rb', line 49
def matched_count return 0 unless acknowledged? if upsert? 0 else n end end
#modified_count ⇒ Integer
Get the number of documents modified.
# File 'lib/mongo/operation/update/result.rb', line 67
def modified_count return 0 unless acknowledged? first[MODIFIED] end
#upserted_count ⇒ Integer
Returns the number of documents upserted.
# File 'lib/mongo/operation/update/result.rb', line 96
def upserted_count upsert? ? n : 0 end
#upserted_id ⇒ Object
The identifier of the inserted document if an upsert
took place.