Class: Mongo::Operation::Commands::UserQuery

Inherits:
Object
  • Object
show all
Includes:
Executable, Specifiable
Defined in:
lib/mongo/operation/commands/user_query.rb

Overview

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

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.

Examples:

Create the user query operation.

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

Since:

  • 2.1.0

Constant Summary

Constants included from Specifiable

Specifiable::BYPASS_DOC_VALIDATION, Specifiable::COLL_NAME, Specifiable::CURSOR_COUNT, Specifiable::CURSOR_ID, Specifiable::CURSOR_IDS, Specifiable::DB_NAME, Specifiable::DELETE, Specifiable::DELETES, Specifiable::DOCUMENTS, Specifiable::INDEX, Specifiable::INDEXES, Specifiable::INDEX_NAME, Specifiable::OPERATION_ID, Specifiable::OPTIONS, Specifiable::READ, Specifiable::READ_CONCERN, Specifiable::SELECTOR, Specifiable::TO_RETURN, Specifiable::UPDATE, Specifiable::UPDATES, Specifiable::USER, Specifiable::USER_NAME, Specifiable::WRITE_CONCERN

Instance Attribute Summary

Attributes included from Specifiable

#spec

Instance Method Summary collapse

Methods included from Specifiable

#==, #bypass_document_validation, #coll_name, #cursor_count, #cursor_id, #cursor_ids, #db_name, #delete, #deletes, #documents, #index, #index_name, #indexes, #initialize, #namespace, #operation_id, #options, #ordered?, #read, #read_concern, #to_return, #update, #updates, #user, #user_name, #write_concern

Instance Method Details

#execute(context) ⇒ Result

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

Parameters:

Returns:

  • (Result)

    The operation response, if there is one.

Since:

  • 2.1.0



45
46
47
48
49
50
51
52
53
# File 'lib/mongo/operation/commands/user_query.rb', line 45

def execute(context)
  if context.features.users_info_enabled?
    UsersInfo.new(spec).execute(context)
  else
    context.with_connection do |connection|
      Result.new(connection.dispatch([ message(context) ])).validate!
    end
  end
end