0

I have a product document, and each product has an array of "productFilters", with this shape:

{
  name: "Filter Name",
  value: "Filter Value",
}

For my params, I have an array of key/value pairs, and I need to check if any of the product filters match the params.

[{ rpm: "3800" }]

How can I write a query that does this? I'm able to do something very simple like this if I have one param, but I have an array of them and don't know how to iterate over it or compare the two arrays:

"products": *[_type == "product"
              && defined(filterValues)
              && $searchName in filterValues[].name
              && $searchValue in filterValues[].value
             ]
greatbearshark
  • 165
  • 1
  • 2
  • 8

0 Answers0