Class: Mongo::Operation::Write::Update::Result
- Defined in:
- lib/mongo/operation/write/update/result.rb
Overview
Defines custom behaviour of results for an update.
Constant Summary collapse
- MODIFIED =
The number of modified docs field in the result.
'nModified'.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.
43 44 45 46 47 48 49 50 |
# File 'lib/mongo/operation/write/update/result.rb', line 43 def matched_count return 0 unless acknowledged? if upsert? 0 else n end end |
#modified_count ⇒ Integer
Get the number of documents modified.
60 61 62 63 |
# File 'lib/mongo/operation/write/update/result.rb', line 60 def modified_count return 0 unless acknowledged? first[MODIFIED] end |
#upserted_id ⇒ Object
The identifier of the inserted document if an upsert
took place.
74 75 76 77 |
# File 'lib/mongo/operation/write/update/result.rb', line 74 def upserted_id return nil unless upsert? upsert?.first['_id'] end |