class Mongo::Operation::CreateIndex::OpMsg

A MongoDB createindex operation sent as an op message.

@api private

@since 2.5.2

Private Instance Methods

selector(connection) click to toggle source
# File lib/mongo/operation/create_index/op_msg.rb, line 31
def selector(connection)
  {
    createIndexes: coll_name,
    indexes: indexes,
    comment: spec[:comment],
  }.compact.tap do |selector|
    if commit_quorum = spec[:commit_quorum]
      # While server versions 3.4 and newer generally perform option
      # validation, there was a bug on server versions 4.2.0 - 4.2.5 where
      # the server would accept the commitQuorum option and use it internally
      # (see SERVER-47193). As a result, the drivers specifications require
      # drivers to perform validation and raise an error when the commitQuorum
      # option is passed to servers that don't support it.
      unless connection.features.commit_quorum_enabled?
        raise Error::UnsupportedOption.commit_quorum_error
      end
      selector[:commitQuorum] = commit_quorum
    end
  end
end