Module: Mongo::Operation::Write::WriteCommandEnabled

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

Overview

This module contains common functionality for operations that send either a write command or a specific wire protocol message, depending on server version. For server versions >= 2.6, a write command is sent.

Since:

  • 2.1.0

Instance Method Summary collapse

Instance Method Details

#execute(server) ⇒ Result

Execute the operation.

Examples:

Execute the operation.

operation.execute(server)

Parameters:

  • server (Mongo::Server)

    The server to send this operation to.

Returns:

  • (Result)

    The operation result.

Since:

  • 2.1.0



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

def execute(server)
  if unacknowledged_write?
    raise Error::UnsupportedCollation.new(Error::UnsupportedCollation::UNACKNOWLEDGED_WRITES_MESSAGE) if has_collation?
    raise Error::UnsupportedArrayFilters.new(Error::UnsupportedArrayFilters::UNACKNOWLEDGED_WRITES_MESSAGE) if has_array_filters?
  end

  if server.features.op_msg_enabled? # version 3.6
    execute_write_command(server)
  else # server version is 2.6 through 3.4
    if unacknowledged_write?
      execute_message(server)
    else
      execute_write_command(server)
    end
  end
end