πŸ‘€ Our most exciting product launch yet πŸš€ Join us May 8th for Sanity Connect

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?