Package com.mongodb.client.result
Class UpdateResult
- java.lang.Object
-
- com.mongodb.client.result.UpdateResult
-
public abstract class UpdateResult extends Object
The result of an update operation. If the update was unacknowledged, thenwasAcknowledged
will return false and all other methods will throwUnsupportedOperationException
.- Since:
- 3.0
- See Also:
WriteConcern.UNACKNOWLEDGED
-
-
Constructor Summary
Constructors Constructor Description UpdateResult()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static UpdateResult
acknowledged(long matchedCount, Long modifiedCount, BsonValue upsertedId)
Create an acknowledged UpdateResultabstract long
getMatchedCount()
Gets the number of documents matched by the query.abstract long
getModifiedCount()
Gets the number of documents modified by the update.abstract BsonValue
getUpsertedId()
If the replace resulted in an inserted document, gets the _id of the inserted document, otherwise null.abstract boolean
isModifiedCountAvailable()
Gets a value indicating whether the modified count is available.static UpdateResult
unacknowledged()
Create an unacknowledged UpdateResultabstract boolean
wasAcknowledged()
Returns true if the write was acknowledged.
-
-
-
Method Detail
-
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
-
isModifiedCountAvailable
public abstract boolean isModifiedCountAvailable()
Gets a value indicating whether the modified count is available.The modified count is only available when all servers have been upgraded to 2.6 or above.
- Returns:
- true if the modified count is available
-
getModifiedCount
public abstract long getModifiedCount()
Gets the number of documents modified by the update.- Returns:
- the number of documents modified
-
getUpsertedId
@Nullable public abstract BsonValue 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
public static UpdateResult unacknowledged()
Create an unacknowledged UpdateResult- Returns:
- an unacknowledged UpdateResult
-
-