Method: Moped::Node#command

Defined in:
lib/moped/node.rb

#command(database, cmd, options = {}) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Execute a command against a database.

Examples:

Execute a command.

node.command(database, { ping: 1 })

Raises:

  • (OperationFailure)

    If the command failed.

Since:

  • 1.0.0



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/moped/node.rb', line 68

def command(database, cmd, options = {})
  operation = Protocol::Command.new(database, cmd, options)

  process(operation) do |reply|
    result = reply.documents.first
    if reply.command_failure?
      if reply.unauthorized? && auth.has_key?(database)
        (database, *auth[database])
        command(database, cmd, options)
      else
        raise Errors::OperationFailure.new(operation, result)
      end
    end
    result
  end
end