
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYes! GROQ absolutely supports fine-grained filtering of array elements based on their content. You can query documents based on conditions within array items, which is exactly what you need.
For your use case with repeatable events, here's how to tie it all together:
*[
_type == "event" &&
hasFixedDate == true &&
count(openingInfo[
eventDate > now() &&
openForRegistration == true
]) > 0
]Let me break down what's happening here:
Array Filtering with []: The openingInfo[...] syntax filters the array, returning only elements that match the conditions inside the brackets. This is GROQ's array filter operator.
Multiple Conditions: Inside the array filter, you can combine conditions with && (AND) or || (OR) operators. Each condition is evaluated in the scope of each array element.
Checking for Matches: The count() function counts how many array elements match your conditions. By checking count(...) > 0, you ensure the document has at least one matching opening.
Here's a more complete example that also returns the matching openings:
*[
_type == "event" &&
hasFixedDate == true &&
count(openingInfo[eventDate > now() && openForRegistration == true]) > 0
] {
title,
"upcomingOpenings": openingInfo[
eventDate > now() &&
openForRegistration == true
]
}Key Points:
[] is evaluated in the scope of each array element@ to refer to the current array element if neededThe GROQ operators documentation has more details on the array filter operator if you need additional examples.
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store