Class: Mongo::Operation::Write::Bulk::Update::LegacyResult

Inherits:
Result
  • Object
show all
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).

Since:

  • 2.0.0

Constant Summary

UPDATED_EXISTING =

The updated existing field in the result.

Since:

  • 2.0.0

'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

#replies

Instance Method Summary collapse

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_matchedInteger

Gets the number of documents matched.

Examples:

Get the matched count.

result.n_matched

Returns:

  • (Integer)

    The number of documents matched.

Since:

  • 2.0.0



160
161
162
163
164
165
166
167
168
169
# 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_modifiedInteger

Gets the number of documents modified.

Examples:

Get the modified count.

result.n_modified

Returns:

  • (Integer)

    The number of documents modified.

Since:

  • 2.2.3



179
# File 'lib/mongo/operation/write/bulk/update/result.rb', line 179

def n_modified; end

#n_upsertedInteger

Gets the number of documents upserted.

Examples:

Get the upserted count.

result.n_upserted

Returns:

  • (Integer)

    The number of documents upserted.

Since:

  • 2.0.0



141
142
143
144
145
146
147
148
149
150
# 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