🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Sanity groq Filter by item in an array

By Surjith S M

This snippet will return only matched item in a sub array inside a document

return only matched variant

// Returns variant name matched in variant[] array

*[_type == "products" && slug.current == $slug][0] {
    variant[type match $variant][0]{
// Params

   "slug": "slug",
   "variant": "variant"

This query will help you to filter a document based on an item match inside an array inside the document.


Other schemas by author