Sanity Library Reference Docs
    Preparing search index...
    Index

    Constructors

    Methods

    • Commit the transaction, returning a promise that resolves to the first mutated document

      Type Parameters

      • R extends Record<string, any>

      Parameters

      • options: TransactionFirstDocumentMutationOptions

        Options for the mutation operation

      Returns Promise<SanityDocument<R>>

    • Commit the transaction, returning a promise that resolves to an array of the mutated documents

      Type Parameters

      • R extends Record<string, any>

      Parameters

      • options: TransactionAllDocumentsMutationOptions

        Options for the mutation operation

      Returns Promise<SanityDocument<R>[]>

    • Commit the transaction, returning a promise that resolves to a mutation result object

      Parameters

      • options: TransactionFirstDocumentIdMutationOptions

        Options for the mutation operation

      Returns Promise<SingleMutationResult>

    • Commit the transaction, returning a promise that resolves to a mutation result object

      Parameters

      • options: TransactionAllDocumentIdsMutationOptions

        Options for the mutation operation

      Returns Promise<MultipleMutationResult>

    • Commit the transaction, returning a promise that resolves to a mutation result object

      Parameters

      • Optionaloptions: BaseMutationOptions

        Options for the mutation operation

      Returns Promise<MultipleMutationResult>

    • 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

    • 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

      • patch: MutationSelection
      • OptionalpatchOps: PatchOperations | PatchBuilder

        Operations to perform, or a builder function

      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