Package com.mongodb.client.model
Class DBCollectionUpdateOptions
- java.lang.Object
-
- com.mongodb.client.model.DBCollectionUpdateOptions
-
public class DBCollectionUpdateOptions extends Object
The options to apply when updating documents in the DBCollection- Since:
- 3.4
- MongoDB documentation
- Updates
- Update Operators
- Update Command
-
-
Constructor Summary
Constructors Constructor Description DBCollectionUpdateOptions()Construct a new instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DBCollectionUpdateOptionsarrayFilters(List<? extends com.mongodb.DBObject> arrayFilters)Sets the array filters optionDBCollectionUpdateOptionsbypassDocumentValidation(Boolean bypassDocumentValidation)Sets the bypass document level validation flag.DBCollectionUpdateOptionscollation(com.mongodb.client.model.Collation collation)Sets the collationDBCollectionUpdateOptionsencoder(DBEncoder encoder)Sets the encoderList<? extends com.mongodb.DBObject>getArrayFilters()Returns the array filters optionBooleangetBypassDocumentValidation()Gets the the bypass document level validation flagcom.mongodb.client.model.CollationgetCollation()Returns the collation optionsDBEncodergetEncoder()Returns the encodercom.mongodb.WriteConcerngetWriteConcern()The write concern to use for the insertion.booleanisMulti()Gets whether all documents matching the query filter will be removed.booleanisUpsert()Returns true if a new document should be inserted if there are no matches to the query filter.DBCollectionUpdateOptionsmulti(boolean multi)Sets whether all documents matching the query filter will be removed.DBCollectionUpdateOptionsupsert(boolean isUpsert)Set to true if a new document should be inserted if there are no matches to the query filter.DBCollectionUpdateOptionswriteConcern(com.mongodb.WriteConcern writeConcern)Sets the write concern
-
-
-
Method Detail
-
isUpsert
public boolean isUpsert()
Returns true if a new document should be inserted if there are no matches to the query filter. The default is false.- Returns:
- true if a new document should be inserted if there are no matches to the query filter
-
upsert
public DBCollectionUpdateOptions upsert(boolean isUpsert)
Set to true if a new document should be inserted if there are no matches to the query filter.- Parameters:
isUpsert- true if a new document should be inserted if there are no matches to the query filter- Returns:
- this
-
getBypassDocumentValidation
@Nullable public Boolean getBypassDocumentValidation()
Gets the the bypass document level validation flag- Returns:
- the bypass document level validation flag
- Since server release
- 3.2
-
bypassDocumentValidation
public DBCollectionUpdateOptions bypassDocumentValidation(@Nullable Boolean bypassDocumentValidation)
Sets the bypass document level validation flag.- Parameters:
bypassDocumentValidation- If true, allows the write to opt-out of document level validation.- Returns:
- this
- Since server release
- 3.2
-
multi
public DBCollectionUpdateOptions multi(boolean multi)
Sets whether all documents matching the query filter will be removed.- Parameters:
multi- true if all documents matching the query filter will be removed- Returns:
- this
-
isMulti
public boolean isMulti()
Gets whether all documents matching the query filter will be removed. The default is true.- Returns:
- whether all documents matching the query filter will be removed
-
getCollation
@Nullable public com.mongodb.client.model.Collation getCollation()
Returns the collation options- Returns:
- the collation options
- Since server release
- 3.4
-
collation
public DBCollectionUpdateOptions collation(@Nullable com.mongodb.client.model.Collation collation)
Sets the collation- Parameters:
collation- the collation- Returns:
- this
- Since server release
- 3.4
-
arrayFilters
public DBCollectionUpdateOptions arrayFilters(@Nullable List<? extends com.mongodb.DBObject> arrayFilters)
Sets the array filters option- Parameters:
arrayFilters- the array filters, which may be null- Returns:
- this
- Since:
- 3.6
- Since server release
- 3.6
-
getArrayFilters
@Nullable public List<? extends com.mongodb.DBObject> getArrayFilters()
Returns the array filters option- Returns:
- the array filters, which may be null
- Since:
- 3.6
- Since server release
- 3.6
-
getWriteConcern
@Nullable public com.mongodb.WriteConcern getWriteConcern()
The write concern to use for the insertion. By default the write concern configured for the DBCollection instance will be used.- Returns:
- the write concern, or null if the default will be used.
-
writeConcern
public DBCollectionUpdateOptions writeConcern(@Nullable com.mongodb.WriteConcern writeConcern)
Sets the write concern- Parameters:
writeConcern- the write concern- Returns:
- this
-
getEncoder
@Nullable public DBEncoder getEncoder()
Returns the encoder- Returns:
- the encoder
-
encoder
public DBCollectionUpdateOptions encoder(@Nullable DBEncoder encoder)
Sets the encoder- Parameters:
encoder- the encoder- Returns:
- this
-
-