class Mongo::Operation::Commands::UserQuery

A MongoDB operation to get info of a particular user in a database.

@example Create the user query operation.

Read::UserQuery.new(:name => 'emily', :db_name => 'test-db')

Initialization:

param [ Hash ] spec The specifications for the user query operation.

option spec :user_name [ String ] The name of the user.
option spec :db_name [ String ] The name of the database where the user exists.
option spec :options [ Hash ] Options for the operation.

@since 2.1.0

Public Instance Methods

execute(server) click to toggle source

Execute the operation.

@example Execute the operation.

operation.execute(server)

@param [ Mongo::Server ] server The server to send this operation to.

@return [ Result ] The operation response, if there is one.

@since 2.1.0

# File lib/mongo/operation/commands/user_query.rb, line 46
def execute(server)
  if server.features.users_info_enabled?
    UsersInfo.new(spec).execute(server).validate!
  else
    server.with_connection do |connection|
      Result.new(connection.dispatch([ message(server) ])).validate!
    end
  end
end

Private Instance Methods

message(server) click to toggle source
# File lib/mongo/operation/commands/user_query.rb, line 66
def message(server)
  Protocol::Query.new(db_name, query_coll, selector, options)
end
query_coll() click to toggle source
# File lib/mongo/operation/commands/user_query.rb, line 62
def query_coll
  Auth::User::COLLECTION
end
selector() click to toggle source
# File lib/mongo/operation/commands/user_query.rb, line 58
def selector
  { :user => user_name }
end