class Mongo::Operation::Delete::BulkResult

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

@since 2.0.0

Public Instance Methods

n_removed() click to toggle source

Gets the number of documents deleted.

@example Get the deleted count.

result.n_removed

@return [ Integer ] The number of documents deleted.

@since 2.0.0

# 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