✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Filter a Reference to show Documents that Contain the Current document's Title in One of the referenced Document's Array Objects

1 replies
Last updated: Feb 5, 2022
I'm currently trying to filter a reference to only show documents that contain the current document's title in one of the referenced document's array objects. So, the `artist document`'s
reference object should only show an array of
documents where that
has been referenced in the project document's
(which is an array of references to all artists). This works :
return {
   filter: 'credits[0]->title == $artist',
   params: { artist: document.title },
But ideally I can loop through all credits :
and see if any titles match the
. Is this possible? If so, any tips as to how I might go about doing this?
Feb 5, 2022, 2:48 AM
$artist in credits[]->title
Feb 5, 2022, 3:07 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?