Class UpdateDescription

java.lang.Object
com.mongodb.client.model.changestream.UpdateDescription

public final class UpdateDescription extends Object
The update description for changed fields in a $changeStream operation.
Since:
3.6
  • Constructor Details

  • Method Details

    • getRemovedFields

      @Nullable public List<String> getRemovedFields()
      Returns the removedFields
      Returns:
      the removedFields
    • getUpdatedFields

      @Nullable public BsonDocument getUpdatedFields()
      Returns information about the updated fields excluding the fields reported via getTruncatedArrays().

      Despite array fields reported via getTruncatedArrays() being excluded from the information returned by this method, changes to fields of the elements of the array values may be reported via this method. For example, given the original field "arrayField": ["foo", {"a": "bar"}, 1, 2, 3] and the updated field "arrayField": ["foo", {"a": "bar", "b": 3}], the following is how such a change may be reported:

      An example showing how the aforementioned change may be reported
      Method Result
      getUpdatedFields() {"arrayField.1.b": 3}
      getTruncatedArrays() {"field": "arrayField", "newSize": 2}
      Returns:
      updatedFields.
      See Also:
    • getTruncatedArrays

      @NonNull public List<TruncatedArray> getTruncatedArrays()
      Returns information about the updated fields of the array type when the changes are reported as truncations.
      Returns:
      truncatedArrays. There are no guarantees on the mutability of the List returned.
      Since:
      4.3
      See Also:
    • getDisambiguatedPaths

      @Nullable public BsonDocument getDisambiguatedPaths()
      A document containing a map that associates an update path to an array containing the path components used in the update document.

      This data can be used in combination with the other fields in an `UpdateDescription` to determine the actual path in the document that was updated. This is necessary in cases where a key contains dot-separated strings (i.e., {"a.b": "c"}) or a document contains a numeric literal string key (i.e., { "a": { "0": "a" } }. Note that in this scenario, the numeric key can't be the top level key, because { "0": "a" } is not ambiguous - update paths would simply be '0' which is unambiguous because BSON documents cannot have arrays at the top level.).

      Each entry in the document maps an update path to an array which contains the actual path used when the document was updated. For example, given a document with the following shape { "a": { "0": 0 } } and an update of { $inc: { "a.0": 1 } }, disambiguatedPaths would look like the following: { "a.0": ["a", "0"] }.

      In each array, all elements will be returned as strings, except for array indices, which will be returned as 32-bit integers.

      Returns:
      the disambiguated paths as a BSON document, which may be null
      Since:
      4.8
      Since server release
      6.1
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
      Returns:
      true if and only if all of the following is true for the compared objects
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object