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

Inherits:
Result
  • Object
show all
Includes:
Aggregatable
Defined in:
lib/mongo/operation/delete/bulk_result.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defines custom behaviour 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

#replies

Instance Method Summary collapse

Methods inherited from Result

#acknowledged?, #cluster_time, #cursor_id, #documents, #each, #initialize, #inspect, #multiple?, #namespace, #ok?, #operation_time, #reply, #returned_count, #successful?, #validate!, #written_count

Constructor Details

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

Instance Method Details

#n_removedInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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



33
34
35
36
37
38
39
40
41
42
# File 'lib/mongo/operation/delete/bulk_result.rb', line 33

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