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

Querying for columns of a specific schema in Sanity

3 replies
Last updated: Jun 13, 2023
If these are my schemas:
footerMenu(document)
   columns(array) of:
      terms(document)
      help(document)

terms(document)
   title
   slug
   ...

help(document)
   title
   slug
   ...
How can I query to get the columns of footerMenu whose slug == "some-slug".

I'm trying something like:

*[_type == "footerMenu"] {
  columns[] {
     "item": *[slug.current == "some-slug"] 
  }
}
But it is clearly wrong.
Thank you!
Jun 10, 2023, 9:08 PM
If I’m understanding correctly, maybe something like this:
*[_type == "footerMenu"] {
  columns[@.slug.current == "some-slug"]
}
Jun 12, 2023, 6:20 PM
That was exactly what I was looking for! Thank you so much, rd : )
Jun 13, 2023, 8:51 AM
You’re welcome!
Jun 13, 2023, 5:18 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?