class Mongo::Operation::Write::Bulk::Update::LegacyResult
Defines custom behaviour of results when updating. For server versions < 2.5.5 (that don't use write commands).
@since 2.0.0
Constants
- UPDATED_EXISTING
The updated existing field in the result.
@since 2.0.0
Public Instance Methods
n_matched()
click to toggle source
Gets the number of documents matched.
@example Get the matched count.
result.n_matched
@return [ Integer ] The number of documents matched.
@since 2.0.0
# File lib/mongo/operation/write/bulk/update/result.rb, line 160 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_modified()
click to toggle source
Gets the number of documents modified.
@example Get the modified count.
result.n_modified
@return [ Integer ] The number of documents modified.
@since 2.2.3
# File lib/mongo/operation/write/bulk/update/result.rb, line 179 def n_modified; end
n_upserted()
click to toggle source
Gets the number of documents upserted.
@example Get the upserted count.
result.n_upserted
@return [ Integer ] The number of documents upserted.
@since 2.0.0
# File lib/mongo/operation/write/bulk/update/result.rb, line 141 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
Private Instance Methods
updated_existing?(reply)
click to toggle source
# File lib/mongo/operation/write/bulk/update/result.rb, line 188 def updated_existing?(reply) reply.documents.first[UPDATED_EXISTING] end
upsert?(reply)
click to toggle source
# File lib/mongo/operation/write/bulk/update/result.rb, line 183 def upsert?(reply) reply.documents.first[BulkWrite::Result::UPSERTED] || (!updated_existing?(reply) && reply.documents.first[N] == 1) end