/** * Returns the collation options * * @return the collation options * @mongodb.server.release 3.4 */ public Collation getCollation() { return options.getCollation(); }
/** * The write concern to use for the delete. * * @return the write concern, or null if the default will be used. */ public WriteConcern getWriteConcern() { return options.getWriteConcern(); }
/** * Remove documents from a collection. * * @param query the deletion criteria using query operators. Omit the query parameter or pass an empty document to delete all * documents in the collection. * @param writeConcern {@code WriteConcern} to be used during operation * @param encoder {@code DBEncoder} to be used * @return the result of the operation * @throws com.mongodb.WriteConcernException if the write failed due some other failure specific to the delete command * @throws MongoException if the operation failed for some other reason * @mongodb.driver.manual tutorial/remove-documents/ Remove Documents */ public WriteResult remove(final DBObject query, final WriteConcern writeConcern, final DBEncoder encoder) { return remove(query, new DBCollectionRemoveOptions().writeConcern(writeConcern).encoder(encoder)); }
/** * Remove documents from a collection. * * @param query the deletion criteria using query operators. Omit the query parameter or pass an empty document to delete all * documents in the collection. * @param writeConcern {@code WriteConcern} to be used during operation * @return the result of the operation * @throws com.mongodb.WriteConcernException if the write failed due some other failure specific to the delete command * @throws MongoException if the operation failed for some other reason * @mongodb.driver.manual tutorial/remove-documents/ Remove Documents */ public WriteResult remove(final DBObject query, final WriteConcern writeConcern) { return remove(query, new DBCollectionRemoveOptions().writeConcern(writeConcern)); }
/** * Remove documents from a collection. * * @param query the deletion criteria using query operators. Omit the query parameter or pass an empty document to delete all * documents in the collection. * @param options the options to apply to the delete operation * @return the result of the operation * @throws com.mongodb.WriteConcernException if the write failed due some other failure specific to the delete command * @throws MongoException if the operation failed for some other reason * @mongodb.driver.manual tutorial/remove-documents/ Remove Documents * @since 3.4 */ public WriteResult remove(final DBObject query, final DBCollectionRemoveOptions options) { notNull("query", query); notNull("options", options); WriteConcern writeConcern = options.getWriteConcern() != null ? options.getWriteConcern() : getWriteConcern(); DeleteRequest deleteRequest = new DeleteRequest(wrap(query, options.getEncoder())).collation(options.getCollation()); return executeWriteOperation(new DeleteOperation(getNamespace(), false, writeConcern, retryWrites, singletonList(deleteRequest))); }
@Test public void passThrough() { Collation collation = Collation.builder() .locale("en") .caseLevel(true) .build(); DBCollectionRemoveOptions options = new DeleteOptions() .collation(collation) .writeConcern(WriteConcern.JOURNALED) .getOptions(); assertEquals(collation, options.getCollation()); assertEquals(WriteConcern.JOURNALED, options.getWriteConcern()); } }
/** * Sets the write concern * * @param writeConcern the write concern * @return this */ public DeleteOptions writeConcern(final WriteConcern writeConcern) { options.writeConcern(writeConcern); return this; }
/** * Sets the collation * * @param collation the collation * @return this * @mongodb.server.release 3.4 */ public DeleteOptions collation(final Collation collation) { options.collation(collation); return this; }
/** * Remove documents from a collection. * * @param query the deletion criteria using query operators. Omit the query parameter or pass an empty document to delete all * documents in the collection. * @param options the options to apply to the delete operation * @return the result of the operation * @throws com.mongodb.WriteConcernException if the write failed due some other failure specific to the delete command * @throws MongoException if the operation failed for some other reason * @mongodb.driver.manual tutorial/remove-documents/ Remove Documents * @since 3.4 */ public WriteResult remove(final DBObject query, final DBCollectionRemoveOptions options) { notNull("query", query); notNull("options", options); WriteConcern writeConcern = options.getWriteConcern() != null ? options.getWriteConcern() : getWriteConcern(); DeleteRequest deleteRequest = new DeleteRequest(wrap(query, options.getEncoder())).collation(options.getCollation()); return executeWriteOperation(new DeleteOperation(getNamespace(), false, writeConcern, retryWrites, singletonList(deleteRequest))); }
/** * Remove documents from a collection. * * @param query the deletion criteria using query operators. Omit the query parameter or pass an empty document to delete all * documents in the collection. * @param writeConcern {@code WriteConcern} to be used during operation * @return the result of the operation * @throws com.mongodb.WriteConcernException if the write failed due some other failure specific to the delete command * @throws MongoException if the operation failed for some other reason * @mongodb.driver.manual tutorial/remove-documents/ Remove Documents */ public WriteResult remove(final DBObject query, final WriteConcern writeConcern) { return remove(query, new DBCollectionRemoveOptions().writeConcern(writeConcern)); }
/** * Sets the write concern * * @param writeConcern the write concern * @return this */ public DeleteOptions writeConcern(final WriteConcern writeConcern) { options.writeConcern(writeConcern); return this; }
/** * Sets the collation * * @param collation the collation * @return this * @mongodb.server.release 3.4 */ public DeleteOptions collation(final Collation collation) { options.collation(collation); return this; }
/** * Remove documents from a collection. * * @param query the deletion criteria using query operators. Omit the query parameter or pass an empty document to delete all * documents in the collection. * @param writeConcern {@code WriteConcern} to be used during operation * @param encoder {@code DBEncoder} to be used * @return the result of the operation * @throws com.mongodb.WriteConcernException if the write failed due some other failure specific to the delete command * @throws MongoException if the operation failed for some other reason * @mongodb.driver.manual tutorial/remove-documents/ Remove Documents */ public WriteResult remove(final DBObject query, final WriteConcern writeConcern, final DBEncoder encoder) { return remove(query, new DBCollectionRemoveOptions().writeConcern(writeConcern).encoder(encoder)); }
/** * Returns the collation options * * @return the collation options * @mongodb.server.release 3.4 */ public Collation getCollation() { return options.getCollation(); }
/** * The write concern to use for the delete. * * @return the write concern, or null if the default will be used. */ public WriteConcern getWriteConcern() { return options.getWriteConcern(); }