driver-legacy/src/main/com/mongodb/DB.java
public CommandResult command(final DBObject command, final ReadPreference readPreference, @Nullable final DBEncoder encoder) {
        try {
            return executeCommand(wrap(command, encoder), getCommandReadPreference(command, readPreference));
        } catch (MongoCommandException ex) {
            return new CommandResult(ex.getResponse(), ex.getServerAddress());
        }
    }
public CommandResult command(final DBObject command, final ReadPreference readPreference, @Nullable final DBEncoder encoder) {
        try {
            return executeCommand(wrap(command, encoder), getCommandReadPreference(command, readPreference));
        } catch (MongoCommandException ex) {
            return new CommandResult(ex.getResponse(), ex.getServerAddress());
        }
    }
public CommandResult command ( final DBObject command , final ReadPreference readPreference , @ Nullable final DBEncoder encoder ) { try { return executeCommand ( wrap ( command , encoder ) , getCommandReadPreference ( command , readPreference ) ) ; } catch ( MongoCommandException ex ) { return new CommandResult ( ex . getResponse ( ) , ex . getServerAddress ( ) ) ; } }
Executes a database command with the selected readPreference, and encodes the command using the given encoder.

@param command        The {@code DBObject} representation the command to be executed
@param readPreference Where to execute the command - this will only be applied for a subset of commands
@param encoder        The DBEncoder that knows how to serialise the command
@return The result of executing the command, success or failure
@mongodb.driver.manual tutorial/use-database-commands Commands
@since 2.12
Executes a database command with the selected readPreference and encodes the command using the given encoder .