Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

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
project
reference object should only show an array of
project
documents where that
artist
has been referenced in the project document's
creditList
(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 :
credits[]->{title}
and see if any titles match the
document.title
. 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
workedšŸ™‚
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?