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

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



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:

Returns:

Since:

  • 2.5.2



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:

Returns:

Since:

  • 2.5.2



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