Package com.mongodb.client.model
Class UpdateOneModel<T>
java.lang.Object
com.mongodb.client.model.WriteModel<T>
com.mongodb.client.model.UpdateOneModel<T>
- Type Parameters:
T- the type of document to update. In practice this doesn't actually apply to updates but is here for consistency with the other write models
A model describing an update to at most one document that matches the query filter. The update to apply must include only update
operators.
- Since:
- 3.0
- MongoDB documentation
- Update Operators
-
Constructor Summary
ConstructorsConstructorDescriptionUpdateOneModel(Bson filter, Bson> update) Construct a new instance.UpdateOneModel(Bson filter, Bson> update, UpdateOptions options) Construct a new instance.UpdateOneModel(Bson filter, Bson update) Construct a new instance.UpdateOneModel(Bson filter, Bson update, UpdateOptions options) Construct a new instance.Method Summary
Modifier and TypeMethodDescriptionGets the query filter.Gets the options to apply.Gets the document specifying the updates to apply to the matching document.Bson>Gets the pipeline specifying the updates to apply to the matching document.toString()-
Constructor Details
-
UpdateOneModel
Construct a new instance.- Parameters:
filter- a document describing the query filter, which may not be null.update- a document describing the update, which may not be null. The update to apply must include only update operators.
-
UpdateOneModel
Construct a new instance.- Parameters:
filter- a document describing the query filter, which may not be null.update- a document describing the update, which may not be null. The update to apply must include only update operators.options- the options to apply
-
UpdateOneModel
Construct a new instance.- Parameters:
filter- a document describing the query filter, which may not be null.update- a pipeline describing the update, which may not be null.- Since:
- 3.11
- Since server release
- 4.2
-
UpdateOneModel
Construct a new instance.- Parameters:
filter- a document describing the query filter, which may not be null.update- a pipeline describing the update, which may not be null.options- the options to apply- Since:
- 3.11
- Since server release
- 4.2
-
-
Method Details
-
getFilter
Gets the query filter.- Returns:
- the query filter
-
getUpdate
Gets the document specifying the updates to apply to the matching document. The update to apply must include only update operators.- Returns:
- the document specifying the updates to apply
-
getUpdatePipeline
Gets the pipeline specifying the updates to apply to the matching document. The update to apply must include only update operators.- Returns:
- the pipeline specifying the updates to apply
- Since:
- 3.11
- Since server release
- 4.2
-
getOptions
Gets the options to apply.- Returns:
- the options
-
toString
- Overrides:
Object
-