Package com.mongodb.client.result
Class UpdateResult
java.lang.Object
com.mongodb.client.result.UpdateResult
The result of an update operation. If the update was unacknowledged, then
wasAcknowledged
will return false and all other
methods will throw UnsupportedOperationException
.- Since:
- 3.0
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic UpdateResult
acknowledged
(long matchedCount, Long modifiedCount, BsonValue upsertedId) Create an acknowledged UpdateResultabstract long
Gets the number of documents matched by the query.abstract long
Gets the number of documents modified by the update.abstract BsonValue
If the replace resulted in an inserted document, gets the _id of the inserted document, otherwise null.static UpdateResult
Create an unacknowledged UpdateResultabstract boolean
Returns true if the write was acknowledged.
-
Constructor Details
-
UpdateResult
public UpdateResult()
-
-
Method Details
-
wasAcknowledged
public abstract boolean wasAcknowledged()Returns true if the write was acknowledged.- Returns:
- true if the write was acknowledged
-
getMatchedCount
public abstract long getMatchedCount()Gets the number of documents matched by the query.- Returns:
- the number of documents matched
-
getModifiedCount
public abstract long getModifiedCount()Gets the number of documents modified by the update.- Returns:
- the number of documents modified
-
getUpsertedId
If the replace resulted in an inserted document, gets the _id of the inserted document, otherwise null.- Returns:
- if the replace resulted in an inserted document, the _id of the inserted document, otherwise null
-
acknowledged
public static UpdateResult acknowledged(long matchedCount, @Nullable Long modifiedCount, @Nullable BsonValue upsertedId) Create an acknowledged UpdateResult- Parameters:
matchedCount
- the number of documents matchedmodifiedCount
- the number of documents modifiedupsertedId
- if the replace resulted in an inserted document, the id of the inserted document- Returns:
- an acknowledged UpdateResult
-
unacknowledged
Create an unacknowledged UpdateResult- Returns:
- an unacknowledged UpdateResult
-