๐Ÿ”ฎ Sanity Create is here. Writing is reinvented. Try now, no developer setup

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?