class Mongo::Operation::CreateIndex::Command

A MongoDB createindex operation sent as a command message.

@api private

@since 2.5.2

Private Instance Methods

message(connection) click to toggle source
# File lib/mongo/operation/create_index/command.rb, line 55
def message(connection)
  Protocol::Query.new(db_name, Database::COMMAND, command(connection), options(connection))
end
selector(connection) click to toggle source
# File lib/mongo/operation/create_index/command.rb, line 35
def selector(connection)
  indexes.each do |index|
    if index[:collation] && !connection.features.collation_enabled?
      raise Error::UnsupportedCollation
    end
  end

  {
    createIndexes: coll_name,
    indexes: indexes,
  }.tap do |selector|
    if commit_quorum = spec[:commit_quorum]
      unless connection.features.commit_quorum_enabled?
        raise Error::UnsupportedOption.commit_quorum_error
      end
      selector[:commitQuorum] = commit_quorum
    end
  end
end