Module: Mongo::Operation::Write

Included in:
Delete, Insert, Update
Defined in:
lib/mongo/operation/shared/write.rb

Overview

Shared behavior of operations that write (update, insert, delete).

Since:

  • 2.5.2

Instance Method Summary collapse

Instance Method Details

#bulk_execute(server) ⇒ Mongo::Operation::Delete::BulkResult, ...

Execute the bulk write operation.

Examples:

operation.bulk_execute(server)

Parameters:

  • server (Mongo::Server)

    The server to send the operation to.

Returns:

Since:

  • 2.5.2



57
58
59
60
61
62
63
# File 'lib/mongo/operation/shared/write.rb', line 57

def bulk_execute(server)
  if server.features.op_msg_enabled?
    self.class::OpMsg.new(spec).execute(server).bulk_result
  else
    self.class::Command.new(spec).execute(server).bulk_result
  end
end

#execute(server) ⇒ Mongo::Operation::Result

Execute the operation.

Examples:

operation.execute(server)

Parameters:

  • server (Mongo::Server)

    The server to send the operation to.

Returns:

Since:

  • 2.5.2



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

def execute(server)
  validate!
  result = if server.features.op_msg_enabled?
      self.class::OpMsg.new(spec).execute(server)
    elsif !acknowledged_write?
      self.class::Legacy.new(spec).execute(server)
    else
      self.class::Command.new(spec).execute(server)
    end
  result.validate!
end