class Mongo::Operation::Explain::Command

A MongoDB explain command operation sent as a command message.

@api private

@since 2.0.0

Private Instance Methods

message(connection) click to toggle source
# File lib/mongo/operation/explain/command.rb, line 52
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/explain/command.rb, line 36
def selector(connection)
  # The mappings are BSON::Documents and as such store keys as
  # strings, the spec here has symbol keys.
  spec = BSON::Document.new(self.spec)

  if spec[:collation] && !connection.features.collation_enabled?
    raise Error::UnsupportedCollation
  end

  {
    explain: {
      find: coll_name,
    }.update(Find::Builder::Command.selector(spec, connection)),
  }.update(spec[:explain] || {})
end