Module: Mongo::Operation::Write Private

Includes:
ResponseHandling
Included in:
Delete, Insert, Update
Defined in:
build/ruby-driver-master/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

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:

Returns:

Since:

  • 2.5.2



64
65
66
67
68
69
70
71
72
# File 'build/ruby-driver-master/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:

Returns:

Since:

  • 2.5.2



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'build/ruby-driver-master/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