Type Alias MutationEvent<R>

MutationEvent: {
    documentId: string;
    effects?: { apply: unknown[]; revert: unknown[] };
    eventId: string;
    identity: string;
    mutations: Mutation[];
    previous?: SanityDocument<R> | null;
    previousRev?: string;
    result?: SanityDocument<R>;
    resultRev?: string;
    timestamp: string;
    transactionCurrentEvent: number;
    transactionId: string;
    transactionTotalEvents: number;
    transition: "update" | "appear" | "disappear";
    type: "mutation";
    visibility: "query" | "transaction";
}

Type Parameters

  • R extends Record<string, Any> = Record<string, Any>

Type declaration

  • documentId: string

    The ID of the document that was affected

  • Optionaleffects?: { apply: unknown[]; revert: unknown[] }

    The effects of the mutation, if the listener was configured with effectFormat: 'mendoza'. Object with apply and revert arrays, see https://github.com/sanity-io/mendoza.

  • eventId: string

    A unique ID for this event

  • identity: string

    The user ID of the user that performed the mutation

  • mutations: Mutation[]

    An array of mutations that were performed. Note that this can differ slightly from the mutations sent to the server, as the server may perform some mutations automatically.

  • Optionalprevious?: SanityDocument<R> | null

    The document as it looked before the mutation was performed. This is only included if the listener was configured with includePreviousRevision: true.

  • OptionalpreviousRev?: string

    The revision ID of the document before the mutation was performed

  • Optionalresult?: SanityDocument<R>

    The document as it looked after the mutation was performed. This is only included if the listener was configured with includeResult: true.

  • OptionalresultRev?: string

    The revision ID of the document after the mutation was performed

  • timestamp: string

    A timestamp for when the mutation was performed

  • transactionCurrentEvent: number

    The index of this event within the transaction. Note that events may be delivered out of order, and that the index is zero-based.

  • transactionId: string

    The transaction ID for the mutation

  • transactionTotalEvents: number

    The total number of events that will be sent for this transaction. Note that this may differ from the amount of documents affected by the transaction, as this number only includes the documents that matches the given filter.

    This can be useful if you need to perform changes to all matched documents atomically, eg you would wait for transactionTotalEvents events with the same transactionId before applying the changes locally.

  • transition: "update" | "appear" | "disappear"

    The type of transition the document went through.

    • update means the document was previously part of the subscribed set of documents, and still is.
    • appear means the document was not previously part of the subscribed set of documents, but is now. This can happen both on create or if updating to a state where it now matches the filter provided to the listener.
    • disappear means the document was previously part of the subscribed set of documents, but is no longer. This can happen both on delete or if updating to a state where it no longer matches the filter provided to the listener.
  • type: "mutation"
  • visibility: "query" | "transaction"

    Whether the change that triggered this event is visible to queries (query) or only to subsequent transactions (transaction). The listener client can specify a preferred visibility through the visibility parameter on the listener, but this is only on a best-effort basis, and may yet not be accurate.