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, then wasAcknowledged will return false and all other methods will throw UnsupportedOperationException.
Since:
4.0
See Also:
  • Constructor Details

    • InsertOneResult

      public InsertOneResult()
  • Method Details

    • 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 null

      Note: 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