Module: Mongo::Operation::Write::Bulk::Delete::Aggregatable

Included in:
LegacyResult, Result
Defined in:
lib/mongo/operation/write/bulk/delete/result.rb

Overview

Defines common r_removed aggreation behaviour.

Since:

  • 2.2.0

Instance Method Summary collapse

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



34
35
36
37
38
39
40
41
42
43
# File 'lib/mongo/operation/write/bulk/delete/result.rb', line 34

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