Class: Mongo::Operation::Write::Update::LegacyResult
- Defined in:
- lib/mongo/operation/write/update/result.rb
Overview
Defines custom behaviour of results for an update on server version <= 2.4.
Constant Summary collapse
- UPDATED_EXISTING =
Whether an existing document was updated.
'updatedExisting'.freeze
- UPSERTED =
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
Instance Method Summary collapse
-
#matched_count ⇒ Integer
Get the number of documents matched.
-
#modified_count ⇒ Integer
Get the number of documents modified.
-
#upserted_id ⇒ Object
The identifier of the inserted document if an upsert took place.
Methods inherited from Result
#acknowledged?, #cursor_id, #documents, #each, #initialize, #inspect, #multiple?, #namespace, #ok?, #reply, #returned_count, #successful?, #validate!, #written_count
Constructor Details
This class inherits a constructor from Mongo::Operation::Result
Instance Method Details
#matched_count ⇒ Integer
Get the number of documents matched.
110 111 112 113 114 115 116 117 |
# File 'lib/mongo/operation/write/update/result.rb', line 110 def matched_count return 0 unless acknowledged? if upsert? 0 else n end end |
#modified_count ⇒ Integer
Get the number of documents modified.
127 128 129 130 131 132 |
# File 'lib/mongo/operation/write/update/result.rb', line 127 def modified_count return 0 unless acknowledged? return n if updated_existing? return 0 if upsert? n end |
#upserted_id ⇒ Object
The identifier of the inserted document if an upsert
took place.
143 144 145 |
# File 'lib/mongo/operation/write/update/result.rb', line 143 def upserted_id first[UPSERTED] if upsert? end |