Class: Mongo::Operation::Delete::BulkResult

Inherits:
Result
  • Object
show all
Includes:
Aggregatable
Defined in:
build/ruby-driver-v2.19/lib/mongo/operation/delete/bulk_result.rb

Overview

Defines custom behavior of results for a delete when part of a bulk write.

Since:

  • 2.0.0

Constant Summary

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

#connection_description, #connection_global_id, #replies

Instance Method Summary collapse

Methods inherited from Result

#acknowledged?, #cluster_time, #cursor_id, #documents, #each, #error, #has_cursor_id?, #initialize, #inspect, #labels, #namespace, #ok?, #operation_time, #reply, #returned_count, #snapshot_timestamp, #successful?, #topology_version, #validate!, #write_concern_error?, #written_count

Constructor Details

This class inherits a constructor from Mongo::Operation::Result

Instance Method Details

#n_removedInteger

Gets the number of documents deleted.

Examples:

Get the deleted count.

result.n_removed

Returns:

  • (Integer)

    The number of documents deleted.

Since:

  • 2.0.0



38
39
40
41
42
43
44
45
46
47
# File 'build/ruby-driver-v2.19/lib/mongo/operation/delete/bulk_result.rb', line 38

def n_removed
  return 0 unless acknowledged?
  @replies.reduce(0) do |n, reply|
    if reply.documents.first[Result::N]
      n += reply.documents.first[Result::N]
    else
      n
    end
  end
end