Class UpdateResult


  • public abstract class UpdateResult
    extends java.lang.Object
    The result of an update operation. If the update was unacknowledged, then wasAcknowledged will return false and all other methods will throw UnsupportedOperationException.
    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, java.lang.Long modifiedCount, org.bson.BsonValue upsertedId)
      Create an acknowledged UpdateResult
      abstract long getMatchedCount()
      Gets the number of documents matched by the query.
      abstract long getModifiedCount()
      Gets the number of documents modified by the update.
      abstract org.bson.BsonValue getUpsertedId()
      If the replace resulted in an inserted document, gets the _id of the inserted document, otherwise null.
      static UpdateResult unacknowledged()
      Create an unacknowledged UpdateResult
      abstract boolean wasAcknowledged()
      Returns true if the write was acknowledged.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UpdateResult

        public UpdateResult()
    • 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
      • getModifiedCount

        public abstract long getModifiedCount()
        Gets the number of documents modified by the update.
        Returns:
        the number of documents modified
      • getUpsertedId

        @Nullable
        public abstract org.bson.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
                                                java.lang.Long modifiedCount,
                                                @Nullable
                                                org.bson.BsonValue upsertedId)
        Create an acknowledged UpdateResult
        Parameters:
        matchedCount - the number of documents matched
        modifiedCount - the number of documents modified
        upsertedId - 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