Sanity Library Reference Docs
    Preparing search index...

    Function getReferencePaths

    • Beta

      Given a document and a reference ID, returns the paths in which the reference is used within the document.

      For example:

      const document = {
      _type: 'test',
      _id: 'test',
      _createdAt: '2021-01-01',
      _updatedAt: '2021-01-01',
      _rev: 'test',
      rootReference: {
      _ref: 'foo-bar',
      _type: 'reference',
      },
      }
      const referencePaths = getReferencePaths(document, 'foo-bar')
      expect(referencePaths).toEqual([['rootReference']])

      Parameters

      Returns Path[]