/** * Gets the {@link ReadPreference}. * * @return the default read preference for this collection * @mongodb.driver.manual core/read-preference/ Read Preference */ public ReadPreference getReadPreference() { if (readPreference != null) { return readPreference; } return database.getReadPreference(); }
/** * Executes a database command. This method constructs a simple DBObject using {@code command} as the field name and {@code true} as its * value, and calls {@link DB#command(DBObject, ReadPreference) } with the default read preference for the database. * * @param command command to execute * @return result of command from the database * @throws MongoException if the command failed * @mongodb.driver.manual tutorial/use-database-commands Commands */ public CommandResult command(final String command) { return command(new BasicDBObject(command, Boolean.TRUE), getReadPreference()); }
/** * Executes a database command. This method calls {@link DB#command(DBObject, ReadPreference) } with the default read preference for the * database. * * @param command {@code DBObject} representation of the command to be executed * @return result of the command execution * @throws MongoException if the command failed * @mongodb.driver.manual tutorial/use-database-commands Commands */ public CommandResult command(final DBObject command) { return command(command, getReadPreference()); }
/** * Executes a database command. This method calls {@link DB#command(DBObject, ReadPreference, DBEncoder) } with the default read * preference for the database. * * @param command {@code DBObject} representation of the command to be executed * @param encoder {@link DBEncoder} to be used for command encoding * @return result of the command execution * @throws MongoException if the command failed * @mongodb.driver.manual tutorial/use-database-commands Commands */ public CommandResult command(final DBObject command, final DBEncoder encoder) { return command(command, getReadPreference(), encoder); }
/** * Gets the {@link ReadPreference}. * * @return the default read preference for this collection * @mongodb.driver.manual core/read-preference/ Read Preference */ public ReadPreference getReadPreference() { if (readPreference != null) { return readPreference; } return database.getReadPreference(); }
/** * Executes a database command. This method calls {@link DB#command(DBObject, ReadPreference) } with the default read preference for the * database. * * @param command {@code DBObject} representation of the command to be executed * @return result of the command execution * @throws MongoException if the command failed * @mongodb.driver.manual tutorial/use-database-commands Commands */ public CommandResult command(final DBObject command) { return command(command, getReadPreference()); }
/** * Executes a database command. This method constructs a simple DBObject using {@code command} as the field name and {@code true} as its * value, and calls {@link DB#command(DBObject, ReadPreference) } with the default read preference for the database. * * @param command command to execute * @return result of command from the database * @throws MongoException if the command failed * @mongodb.driver.manual tutorial/use-database-commands Commands */ public CommandResult command(final String command) { return command(new BasicDBObject(command, Boolean.TRUE), getReadPreference()); }
/** * Executes a database command. This method calls {@link DB#command(DBObject, ReadPreference, DBEncoder) } with the default read * preference for the database. * * @param command {@code DBObject} representation of the command to be executed * @param encoder {@link DBEncoder} to be used for command encoding * @return result of the command execution * @throws MongoException if the command failed * @mongodb.driver.manual tutorial/use-database-commands Commands */ public CommandResult command(final DBObject command, final DBEncoder encoder) { return command(command, getReadPreference(), encoder); }