Class: Mongo::Operation::Write::Bulk::Update::LegacyResult
- Includes:
- LegacyMergable
- Defined in:
- lib/mongo/operation/write/bulk/update/result.rb
Overview
Defines custom behaviour of results when updating. For server versions < 2.5.5 (that don’t use write commands).
Constant Summary collapse
- UPDATED_EXISTING =
The updated existing field in the result.
'updatedExisting'.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
-
#n_matched ⇒ Integer
(also: #n_modified)
Gets the number of documents matched.
-
#n_upserted ⇒ Integer
Gets the number of documents upserted.
Methods included from LegacyMergable
#aggregate_write_concern_errors, #aggregate_write_errors
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
#n_matched ⇒ Integer Also known as: n_modified
Gets the number of documents matched.
148 149 150 151 152 153 154 155 156 157 |
# File 'lib/mongo/operation/write/bulk/update/result.rb', line 148 def n_matched return 0 unless acknowledged? @replies.reduce(0) do |n, reply| if upsert?(reply) n else n += reply.documents.first[N] end end end |
#n_upserted ⇒ Integer
Gets the number of documents upserted.
129 130 131 132 133 134 135 136 137 138 |
# File 'lib/mongo/operation/write/bulk/update/result.rb', line 129 def n_upserted return 0 unless acknowledged? @replies.reduce(0) do |n, reply| if upsert?(reply) n += reply.documents.first[N] else n end end end |