Sanity Library Reference Docs
    Preparing search index...

    Class ObservableTransaction

    Hierarchy

    • BaseTransaction
      • ObservableTransaction
    Index

    Constructors

    Methods

    • Commit the transaction, returning an observable that produces the first mutated document

      Type Parameters

      • R extends Record<string, any>

      Parameters

      • options: TransactionFirstDocumentMutationOptions

        Options for the mutation operation

      Returns Observable<SanityDocument<R>>

    • Commit the transaction, returning an observable that produces an array of the mutated documents

      Type Parameters

      • R extends Record<string, any>

      Parameters

      • options: TransactionAllDocumentsMutationOptions

        Options for the mutation operation

      Returns Observable<SanityDocument<R>[]>

    • Commit the transaction, returning an observable that produces a mutation result object

      Parameters

      • options: TransactionFirstDocumentIdMutationOptions

        Options for the mutation operation

      Returns Observable<SingleMutationResult>

    • Commit the transaction, returning an observable that produces a mutation result object

      Parameters

      • options: TransactionAllDocumentIdsMutationOptions

        Options for the mutation operation

      Returns Observable<MultipleMutationResult>

    • Commit the transaction, returning an observable that produces a mutation result object

      Parameters

      Returns Observable<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

    • 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 | ObservablePatchBuilder

        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

      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