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



70
71
72
73
74
75
76
77
78
# File 'lib/mongo/operation/shared/write.rb', line 70

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
# File 'lib/mongo/operation/shared/write.rb', line 37

def execute(server, context:)
  server.with_connection(connection_global_id: context.connection_global_id) do |connection|
    execute_with_connection(connection, context: context)
  end
end

#execute_with_connection(connection, 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 connection to send the operation through.

  • The operation context.

  • Operation execution options.

Returns:

  • The operation result.

Since:

  • 2.5.2

API:

  • private



51
52
53
54
55
56
57
# File 'lib/mongo/operation/shared/write.rb', line 51

def execute_with_connection(connection, context:)
  validate!(connection)
  op = self.class::OpMsg.new(spec)

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