Shopify + Sanity: Read about the investment and partnership –>

Match an array against another array in GROQ

By Carl Filip Matre & RD Pennell

query/params

*[_type == 'movie' && count((castMembers[].person._ref)[@ in $ids]) > 0].title

{
  ids: ['person_chris-pratt', 'person_noomi-rapace']
}

@cfmatre originally came up with this brilliant method for matching an array of items against another array in GROQ but, unfortunately, it was lost to Slack history. Here, I've adapted the query to work with the Movies DB to provide access to all members of the community!

Contributors

Other schemas by authors