class Mongo::Operation::Update::Legacy::Result
Defines custom behavior of results for an update on server version <= 2.4.
@since 2.0.0 @api semiprivate
Constants
- UPDATED_EXISTING
Whether an existing document was updated.
@since 2.0.0 @api private
- UPSERTED
The upserted docs field in the result.
@since 2.0.0 @api private
Public Instance Methods
Get the number of documents matched.
@example Get the matched count.
result.matched_count
@return [ Integer ] The matched count.
@since 2.0.0 @api public
# File lib/mongo/operation/update/legacy/result.rb, line 49 def matched_count return 0 unless acknowledged? if upsert? 0 else n end end
Get the number of documents modified.
@example Get the modified count.
result.modified_count
@return [ nil ] Always omitted for legacy versions.
@since 2.0.0 @api public
# File lib/mongo/operation/update/legacy/result.rb, line 67 def modified_count; end
Returns the number of documents upserted.
@example Get the number of upserted documents.
result.upserted_count
@return [ Integer ] The number upserted.
@since 2.4.2 @api public
# File lib/mongo/operation/update/legacy/result.rb, line 92 def upserted_count upsert? ? n : 0 end
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 @api public
# File lib/mongo/operation/update/legacy/result.rb, line 79 def upserted_id first[UPSERTED] if upsert? end
Private Instance Methods
# File lib/mongo/operation/update/legacy/result.rb, line 102 def updated_existing? first[UPDATED_EXISTING] end
# File lib/mongo/operation/update/legacy/result.rb, line 98 def upsert? !updated_existing? && n == 1 end