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(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.1.0
# 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
Private Instance Methods
message(context)
click to toggle source
# File lib/mongo/operation/commands/user_query.rb, line 65 def message(context) 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 61 def query_coll Auth::User::COLLECTION end
selector()
click to toggle source
# File lib/mongo/operation/commands/user_query.rb, line 57 def selector { :user => user_name } end