class Mongo::Operation::Write::Update::LegacyResult
Defines custom behaviour of results for an update on server version <= 2.4.
@since 2.0.0
Constants
- UPDATED_EXISTING
Whether an existing document was updated.
@since 2.0.0
- UPSERTED
The upserted docs field in the result.
@since 2.0.0
Public Instance Methods
matched_count()
click to toggle source
Get the number of documents matched.
@example Get the matched count.
result.matched_count
@return [ Integer ] The matched count.
@since 2.0.0
# 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()
click to toggle source
Get the number of documents modified.
@example Get the modified count.
result.modified_count
@return [ Integer ] The modified count.
@since 2.0.0
# 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()
click to toggle source
The identifier of the inserted document if an upsert
took place.
@example Get the upserted document's identifier.
result.upserted_id
@return [ Object ] The upserted id.
@since 2.0.0
# File lib/mongo/operation/write/update/result.rb, line 143 def upserted_id first[UPSERTED] if upsert? end
Private Instance Methods
updated_existing?()
click to toggle source
# File lib/mongo/operation/write/update/result.rb, line 153 def updated_existing? first[UPDATED_EXISTING] end
upsert?()
click to toggle source
# File lib/mongo/operation/write/update/result.rb, line 149 def upsert? !updated_existing? && n == 1 end