Class CompactChangeEvent<DocumentT>

  • Type Parameters:
    DocumentT - The underlying type of document for which this change event was produced.

    public final class CompactChangeEvent<DocumentT>
    extends BaseChangeEvent<DocumentT>
    Represents a change event communicated via a MongoDB change stream from Stitch when watchCompact is called. These change events omit full documents from the event for updates, as well as other fields that are unnecessary in the context of Stitch.
    • Constructor Detail

      • CompactChangeEvent

        public CompactChangeEvent​(@Nonnull
                                  OperationType operationType,
                                  @Nullable
                                  DocumentT fullDocument,
                                  @Nonnull
                                  BsonDocument documentKey,
                                  @Nullable
                                  UpdateDescription updateDescription,
                                  @Nullable
                                  DocumentVersionInfo.Version stitchDocumentVersion,
                                  @Nullable
                                  Long stitchDocumentHash,
                                  boolean hasUncommittedWrites)
        Constructs a change event.
        Parameters:
        operationType - The operation type represented by the change event.
        fullDocument - The full document of this change event (for inserts and updates)
        documentKey - The id if the underlying document that changed.
        updateDescription - The description of what has changed (for updates only).
        stitchDocumentVersion - The Stitch sync version of this document at the time of the event.
        stitchDocumentHash - The Stitch sync hash of this document at the time of the event.
        hasUncommittedWrites - Whether this represents a local uncommitted write.
    • Method Detail

      • getStitchDocumentVersion

        @Nullable
        public DocumentVersionInfo.Version getStitchDocumentVersion()
        Returns the MongoDB Mobile Sync version of the document after this event, if it exists on the document after the update.
        Returns:
        the sync document version
      • getStitchDocumentVersionInfo

        @Nonnull
        public DocumentVersionInfo getStitchDocumentVersionInfo()
        Returns the MongoDB Mobile Sync version info of the document after this event.
        Returns:
        the sync document version info
      • getStitchDocumentHash

        @Nullable
        public Long getStitchDocumentHash()
        Returns the FNV-1a hash of the document as computed after the rules were applied, and after the document version was removed from the document.
        Returns:
        the sync document hash
      • withoutUncommittedWrites

        public CompactChangeEvent<DocumentT> withoutUncommittedWrites()
        Creates a copy of this change event with uncommitted writes flag set to false.
        Returns:
        new change event without uncommitted writes flag
      • fromBsonDocument

        public static CompactChangeEvent fromBsonDocument​(BsonDocument document)
        Deserializes a BsonDocument into an instance of change event.
        Parameters:
        document - the serialized document
        Returns:
        the deserialized change event