Class Transaction

Hierarchy (View Summary)

Constructors

Properties

operations: Mutation[]
trxId?: string

Methods

  • Creates a new Sanity document. If _id is provided and already exists, the mutation will fail. If no _id is given, one will automatically be generated by the database. The operation is added to the current transaction, ready to be commited by commit()

    Type Parameters

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

    Parameters

    Returns this

  • Creates a new Sanity document. If a document with the same _id already exists, the create operation will be ignored. The operation is added to the current transaction, ready to be commited by commit()

    Type Parameters

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

    Parameters

    Returns this

  • Creates a new Sanity document, or replaces an existing one if the same _id is already used. The operation is added to the current transaction, ready to be commited by commit()

    Type Parameters

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

    Parameters

    Returns this

  • Deletes the document with the given document ID The operation is added to the current transaction, ready to be commited by commit()

    Parameters

    • documentId: string

      Document ID to delete

    Returns this

  • Performs a patch on the given document ID. Can either be a builder function or an object of patch operations. The operation is added to the current transaction, ready to be commited by commit()

    Parameters

    • documentId: string

      Document ID to perform the patch operation on

    • OptionalpatchOps: PatchOperations | PatchBuilder

      Operations to perform, or a builder function

    Returns this

  • Performs a patch on the given selection. Can either be a builder function or an object of patch operations.

    Parameters

    Returns this

  • Adds the given patch instance to the transaction. The operation is added to the current transaction, ready to be commited by commit()

    Parameters

    • patch: Patch

      Patch to execute

    Returns this

  • Clears the transaction of all operations

    Returns this

  • Gets the current transaction ID, if any

    Returns undefined | string

  • Set the ID of this transaction.

    Parameters

    • id: string

      Transaction ID

    Returns this