Class: Mongo::Operation::Update::Result
- Defined in:
- lib/mongo/operation/update/result.rb
Overview
Defines custom behavior of results for an update.
Constant Summary collapse
- MODIFIED =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The number of modified docs field in the result.
'nModified'.freeze
- UPSERTED =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The upserted docs field in the result.
'upserted'.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
#connection, #connection_description, #connection_global_id, #context, #replies
Instance Method Summary collapse
- #bulk_result ⇒ Object
-
#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 took place.
Methods inherited from Result
#acknowledged?, #cluster_time, #cursor_id, #documents, #each, #error, #has_cursor_id?, #initialize, #inspect, #labels, #namespace, #ok?, #operation_time, #reply, #returned_count, #snapshot_timestamp, #successful?, #topology_version, #validate!, #write_concern_error?, #written_count
Constructor Details
This class inherits a constructor from Mongo::Operation::Result
Instance Method Details
#bulk_result ⇒ Object
101 102 103 |
# 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.
49 50 51 52 53 54 55 56 |
# 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.
67 68 69 70 |
# 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.
96 97 98 |
# 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.
82 83 84 85 |
# File 'lib/mongo/operation/update/result.rb', line 82 def upserted_id return nil unless upsert? upsert?.first['_id'] end |