class Mongo::Operation::Commands::CollectionsInfo

A MongoDB operation to get a list of collection names in a database.

@example Create the collection names operation.

Read::CollectionNames.new(:db_name => 'test-db')

Initialization:

param [ Hash ] spec The specifications for the collection names operation.

option spec :db_name [ String ] The name of the database whose collection
  names is requested.
option spec :options [ Hash ] Options for the operation.

@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 operation response, if there is one.

@since 2.0.0

# File lib/mongo/operation/commands/collections_info.rb, line 48
def execute(context)
  if context.features.list_collections_enabled?
    ListCollections.new(spec).execute(context)
  else
    context.with_connection do |connection|
      Result.new(connection.dispatch([ message(context) ])).validate!
    end
  end
end

Private Instance Methods

query_coll() click to toggle source
# File lib/mongo/operation/commands/collections_info.rb, line 64
def query_coll
  Database::NAMESPACES
end
selector() click to toggle source
# File lib/mongo/operation/commands/collections_info.rb, line 60
def selector
  { :name => { '$not' => /system\.|\$/ } }
end