Package com.mongodb
Class WriteConcernResult
java.lang.Object
com.mongodb.WriteConcernResult
The result of a successful write operation. If the write was unacknowledged, then
wasAcknowledged
will return false and all
other methods will throw MongoUnacknowledgedWriteException
.- Since:
- 3.0
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic WriteConcernResult
acknowledged
(int count, boolean isUpdateOfExisting, BsonValue upsertedId) Create an acknowledged WriteConcernResultabstract int
getCount()
Returns the number of documents affected by the write operation.abstract BsonValue
Returns the value of _id if this write resulted in an upsert.abstract boolean
Returns true if the write was an update of an existing document.static WriteConcernResult
Create an unacknowledged WriteConcernResultabstract boolean
Returns true if the write was acknowledged.
-
Constructor Details
-
WriteConcernResult
public WriteConcernResult()
-
-
Method Details
-
wasAcknowledged
public abstract boolean wasAcknowledged()Returns true if the write was acknowledged.- Returns:
- true if the write was acknowledged
-
getCount
public abstract int getCount()Returns the number of documents affected by the write operation.- Returns:
- the number of documents affected by the write operation
- Throws:
UnsupportedOperationException
- if the write was unacknowledged.
-
isUpdateOfExisting
public abstract boolean isUpdateOfExisting()Returns true if the write was an update of an existing document.- Returns:
- true if the write was an update of an existing document
- Throws:
UnsupportedOperationException
- if the write was unacknowledged.
-
getUpsertedId
Returns the value of _id if this write resulted in an upsert.- Returns:
- the value of _id if this write resulted in an upsert.
- Throws:
UnsupportedOperationException
- if the write was unacknowledged.
-
acknowledged
public static WriteConcernResult acknowledged(int count, boolean isUpdateOfExisting, @Nullable BsonValue upsertedId) Create an acknowledged WriteConcernResult- Parameters:
count
- the count of matched documentsisUpdateOfExisting
- whether an existing document was updatedupsertedId
- if an upsert resulted in an inserted document, this is the _id of that document. This may be null- Returns:
- an acknowledged WriteConcernResult
-
unacknowledged
Create an unacknowledged WriteConcernResult- Returns:
- an unacknowledged WriteConcernResult
-