Package com.mongodb.client.model
Class UpdateOptions
-
- com.mongodb.client.model.UpdateOptions
-
public class UpdateOptions extends
The options to apply when updating documents.- Since:
- 3.0
- MongoDB documentation
-
-
Constructor Summary
Constructors Constructor Description UpdateOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UpdateOptions
<? extends Bson> arrayFilters)
Sets the array filters optionUpdateOptions
bypassDocumentValidation)
Sets the bypass document level validation flag.UpdateOptions
collation(Collation collation)
Sets the collation options<? extends Bson>
getArrayFilters()
Returns the array filters optiongetBypassDocumentValidation()
Gets the the bypass document level validation flagCollation
getCollation()
Returns the collation optionsboolean
isUpsert()
Returns true if a new document should be inserted if there are no matches to the query filter.toString()
UpdateOptions
upsert(boolean upsert)
Set to true if a new document should be inserted if there are no matches to the query filter.
-
-
-
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 UpdateOptions upsert(boolean upsert)
Set to true if a new document should be inserted if there are no matches to the query filter.- Parameters:
upsert
- true if a new document should be inserted if there are no matches to the query filter- Returns:
- this
-
getBypassDocumentValidation
@Nullable public getBypassDocumentValidation()
Gets the the bypass document level validation flag- Returns:
- the bypass document level validation flag
- Since:
- 3.2
- Since server release
-
bypassDocumentValidation
public UpdateOptions bypassDocumentValidation(@Nullable 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:
- 3.2
- Since server release
-
getCollation
@Nullable public Collation getCollation()
Returns the collation options- Returns:
- the collation options
- Since:
- 3.4
- Since server release
-
collation
public UpdateOptions collation(@Nullable Collation collation)
Sets the collation optionsA null value represents the server default.
- Parameters:
collation
- the collation options to use- Returns:
- this
- Since:
- 3.4
- Since server release
-
arrayFilters
public UpdateOptions arrayFilters(@Nullable <? extends Bson> arrayFilters)
Sets the array filters option- Parameters:
arrayFilters
- the array filters, which may be null- Returns:
- this
- Since:
- 3.6
- Since server release
-
getArrayFilters
@Nullable public <? extends Bson> getArrayFilters()
Returns the array filters option- Returns:
- the array filters, which may be null
- Since:
- 3.6
- Since server release
-
toString
public toString()
- Overrides:
in class
-
-