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 the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?