Package com.mongodb.client.result
Class InsertOneResult
- java.lang.Object
-
- com.mongodb.client.result.InsertOneResult
-
public abstract class InsertOneResult extends Object
The result of an insert one operation. If the insert one was unacknowledged, thenwasAcknowledged
will return false and all other methods will throwUnsupportedOperationException
.- Since:
- 4.0
- See Also:
WriteConcern.UNACKNOWLEDGED
-
-
Constructor Summary
Constructors Constructor Description InsertOneResult()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static InsertOneResult
acknowledged(BsonValue insertId)
Create an acknowledged InsertOneResultabstract BsonValue
getInsertedId()
If the _id of the inserted document if available, otherwise nullstatic InsertOneResult
unacknowledged()
Create an unacknowledged InsertOneResultabstract 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
-
getInsertedId
@Nullable public abstract BsonValue getInsertedId()
If the _id of the inserted document if available, otherwise nullNote: Inserting RawBsonDocuments does not generate an _id value.
- Returns:
- if _id of the inserted document if available, otherwise null
-
acknowledged
public static InsertOneResult acknowledged(@Nullable BsonValue insertId)
Create an acknowledged InsertOneResult- Parameters:
insertId
- the id of the inserted document- Returns:
- an acknowledged InsertOneResult
-
unacknowledged
public static InsertOneResult unacknowledged()
Create an unacknowledged InsertOneResult- Returns:
- an unacknowledged InsertOneResult
-
-