class Mongo::Operation::Commands::Indexes

A MongoDB get indexes operation.

Initialize the get indexes operation.

@example Instantiate the operation.

Read::Indexes.new(:db_name => 'test', :coll_name => 'test_coll')

Initialization:

param [ Hash ] spec The specifications for the insert.

option spec :db_name [ String ] The name of the database.
option spec :coll_name [ String ] The name of the collection.

@since 2.0.0

Public Instance Methods

execute(context) click to toggle source

Execute the operation. The context gets a connection on which the operation is sent in the block.

@param [ Mongo::Server::Context ] context The context for this operation.

@return [ Result ] The indexes operation response.

@since 2.0.0

# File lib/mongo/operation/commands/indexes.rb, line 46
def execute(context)
  if context.features.list_indexes_enabled?
    ListIndexes.new(spec).execute(context)
  else
    execute_message(context)
  end
end

Private Instance Methods

execute_message(context) click to toggle source
# File lib/mongo/operation/commands/indexes.rb, line 56
def execute_message(context)
  context.with_connection do |connection|
    Result.new(connection.dispatch([ message(context) ]))
  end
end
query_coll() click to toggle source
# File lib/mongo/operation/commands/indexes.rb, line 66
def query_coll
  Index::COLLECTION
end
selector() click to toggle source
# File lib/mongo/operation/commands/indexes.rb, line 62
def selector
  { ns: namespace }
end