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

Structure: Filter is required

Certain nodes within the desk structure requires a filter. A filter is the part of a GROQ-query which specifies which documents should be matched - the constraints of a query, if you will.

Let's imagine you want to run a query to find all documents that do not currently have a slug set (in a field called slug). While the full GROQ-query would look like this:

*[!defined(slug.current)]

The filter of the query is simply:

!defined(slug.current)

Setting a filter can be done by calling the filter() method:

S.documentList()
  .title('Missing slug')
.filter('!defined(slug.current)')

Was this article helpful?