Class ObservableSanityClient

Constructors

Properties

listen: {
    <R extends Record<string, any> = Record<string, any>>(
        this: ObservableSanityClient | SanityClient,
        query: string,
        params?: ListenParams,
    ): Observable<MutationEvent<R>>;
    <R extends Record<string, any> = Record<string, any>>(
        this: ObservableSanityClient | SanityClient,
        query: string,
        params?: ListenParams,
        options?: ListenOptions,
    ): Observable<ListenEvent<R>>;
} = _listen

Instance properties

Type declaration

Methods

  • Deletes a document with the given document ID. Returns an observable that resolves to the deleted document.

    Type Parameters

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

    Parameters

    Returns Observable<SanityDocument<R>>

  • Deletes a document with the given document ID. Returns an observable that resolves to an array containing the deleted document.

    Type Parameters

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

    Parameters

    Returns Observable<SanityDocument<R>[]>

  • Deletes a document with the given document ID. Returns an observable that resolves to a mutation result object containing the deleted document ID.

    Parameters

    Returns Observable<SingleMutationResult>

  • Deletes a document with the given document ID. Returns an observable that resolves to a mutation result object containing the deleted document ID.

    Parameters

    Returns Observable<MultipleMutationResult>

  • Deletes a document with the given document ID. Returns an observable that resolves to the deleted document.

    Type Parameters

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

    Parameters

    Returns Observable<SanityDocument<R>>

  • Deletes one or more documents matching the given query or document ID. Returns an observable that resolves to first deleted document.

    Type Parameters

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

    Parameters

    Returns Observable<SanityDocument<R>>

  • Deletes one or more documents matching the given query or document ID. Returns an observable that resolves to an array containing the deleted documents.

    Type Parameters

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

    Parameters

    Returns Observable<SanityDocument<R>[]>

  • Deletes one or more documents matching the given query or document ID. Returns an observable that resolves to a mutation result object containing the ID of the first deleted document.

    Parameters

    Returns Observable<SingleMutationResult>

  • Deletes one or more documents matching the given query or document ID. Returns an observable that resolves to a mutation result object containing the document IDs that were deleted.

    Parameters

    Returns Observable<MultipleMutationResult>

  • Deletes one or more documents matching the given query or document ID. Returns an observable that resolves to first deleted document.

    Type Parameters

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

    Parameters

    Returns Observable<SanityDocument<R>>

  • Get a Sanity API URL for the data operation and path provided

    Parameters

    • operation: string

      Data operation (eg query, mutate, listen or similar)

    • Optionalpath: string

      Path to append after the operation

    Returns string

  • Fetch a single document with the given ID.

    Type Parameters

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

    Parameters

    • id: string

      Document ID to fetch

    • Optionaloptions: { tag?: string }

      Request options

    Returns Observable<undefined | SanityDocument<R>>

  • Fetch multiple documents in one request. Should be used sparingly - performing a query is usually a better option. The order/position of documents is preserved based on the original array of IDs. If any of the documents are missing, they will be replaced by a null entry in the returned array

    Type Parameters

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

    Parameters

    • ids: string[]

      Document IDs to fetch

    • Optionaloptions: { tag?: string }

      Request options

    Returns Observable<(null | SanityDocument<R>)[]>

  • Get a Sanity API URL for the URI provided

    Parameters

    • uri: string

      URI/path to build URL for

    • OptionalcanUseCdn: boolean

      Whether or not to allow using the API CDN for this route

    Returns string

  • Create a new buildable patch of operations to perform

    Parameters

    • documentId: string

      Document ID to patch

    • Optionaloperations: PatchOperations

      Optional object of patch operations to initialize the patch instance with

    Returns ObservablePatch

    Patch instance - call .commit() to perform the operations defined

  • Create a new buildable patch of operations to perform

    Parameters

    • documentIds: string[]

      Array of document IDs to patch

    • Optionaloperations: PatchOperations

      Optional object of patch operations to initialize the patch instance with

    Returns ObservablePatch

    Patch instance - call .commit() to perform the operations defined

  • Create a new buildable patch of operations to perform

    Parameters

    • selection: MutationSelection

      An object with query and optional params, defining which document(s) to patch

    • Optionaloperations: PatchOperations

      Optional object of patch operations to initialize the patch instance with

    Returns ObservablePatch

    Patch instance - call .commit() to perform the operations defined

  • Perform an HTTP request against the Sanity API

    Type Parameters

    • R = any

    Parameters

    Returns Observable<R>

  • Create a new transaction of mutations

    Type Parameters

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

    Parameters

    • Optionaloperations: Mutation<R>[]

      Optional array of mutation operations to initialize the transaction instance with

    Returns ObservableTransaction