Package com.mongodb
Class WriteResult
java.lang.Object
com.mongodb.WriteResult
This class lets you access the results of the previous acknowledged write. If the write was unacknowledged, all property access
 methods will throw 
UnsupportedOperationException.- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionWriteResult(int n, boolean updateOfExisting, Object upsertedId) Construct a new instance.
- 
Method SummaryModifier and TypeMethodDescriptionintgetN()Gets the "n" field, which contains the number of documents affected in the write operation.Gets the _id value of an upserted document that resulted from this write.booleanReturns true if this write resulted in an update of an existing document.toString()static WriteResultGets an instance representing an unacknowledged write.booleanReturns true if the write was acknowledged.
- 
Constructor Details- 
WriteResultConstruct a new instance.- Parameters:
- n- the number of existing documents affected by this operation
- updateOfExisting- true if the operation was an update and an existing document was updated
- upsertedId- the _id of a document that was upserted by this operation, which may be null
 
 
- 
- 
Method Details- 
unacknowledgedGets an instance representing an unacknowledged write.- Returns:
- an instance representing an unacknowledged write
- Since:
- 3.0
 
- 
wasAcknowledgedpublic boolean wasAcknowledged()Returns true if the write was acknowledged.- Returns:
- true if the write was acknowledged
- Since:
- 3.0
- See Also:
 
- 
getNpublic int getN()Gets the "n" field, which contains the number of documents affected in the write operation.- Returns:
- the value of the "n" field
- Throws:
- UnsupportedOperationException- if the write was unacknowledged
- See Also:
 
- 
getUpsertedIdGets the _id value of an upserted document that resulted from this write.- Returns:
- the value of the _id of an upserted document, which may be null
- Throws:
- UnsupportedOperationException- if the write was unacknowledged
- Since:
- 2.12
 
- 
isUpdateOfExistingpublic boolean isUpdateOfExisting()Returns true if this write resulted in an update of an existing document.- Returns:
- whether the write resulted in an update of an existing document.
- Throws:
- UnsupportedOperationException- if the write was unacknowledged
- Since:
- 2.12
 
- 
toString
 
-