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

Is it possible to match values in arrays using a groq query in Sanity.io?

2 replies
Last updated: Oct 18, 2023
Is it possible to match any value in an array with another array in a groq query? šŸ¤”
Something like this:
*[_type == "event" && ^.filter.tags[]._ref in tags[]._ref && eventStart > now()]
?
Oct 18, 2023, 5:06 PM
Asked ChatGPT and it hallucinated a
some
keyword. šŸ˜›
Oct 18, 2023, 5:13 PM
Figured it out.

*[_type == "event" && count((tags[]._ref)[@ in  ^.filter.tags[]._ref]) > 0 && eventStart > now()]
Oct 18, 2023, 7:46 PM

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?