Module: Mongo::Operation::Write Private

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

Overview

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

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

Since:

  • 2.5.2

API:

  • private

Instance Method Summary collapse

Instance Method Details

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

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.

Execute the bulk write operation.

Parameters:

  • The connection over which to send the operation.

  • The operation context.

Returns:

  • The bulk result.

Since:

  • 2.5.2

API:

  • private



64
65
66
67
68
69
70
71
72
# File 'lib/mongo/operation/shared/write.rb', line 64

def bulk_execute(connection, context:)
  Lint.assert_type(connection, Server::Connection)

  if connection.features.op_msg_enabled?
    self.class::OpMsg.new(spec).execute(connection, context: context).bulk_result
  else
    self.class::Command.new(spec).execute(connection, context: context).bulk_result
  end
end

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

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.

Execute the operation.

Parameters:

  • The server to send the operation to.

  • The operation context.

Returns:

  • The operation result.

Since:

  • 2.5.2

API:

  • private



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/mongo/operation/shared/write.rb', line 37

def execute(server, context:)
  server.with_connection(service_id: context.service_id) do |connection|
    validate!(connection)
    op = if connection.features.op_msg_enabled?
        self.class::OpMsg.new(spec)
      elsif !acknowledged_write?
        self.class::Legacy.new(spec)
      else
        self.class::Command.new(spec)
      end

    result = op.execute(connection, context: context)
    validate_result(result, connection, context)
  end
end