
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeBased on your query structure, you're dealing with nested arrays and trying to flatten them while extracting a specific property. The key issue is that you need to properly flatten the nested tasks[].tasks[] structure and then project the usedTime property.
Here's how to achieve what you're after:
*[_type == "internalCustomers" && 'myMail@mail.com' in users[]->email]{
"totalHours": tasks[].tasks[].usedTime
}This syntax tasks[].tasks[].usedTime will:
tasks arraytasks arrayusedTime property from each taskThe double array projection ([][]) handles the flattening for you - GROQ automatically flattens nested arrays when you chain array projections like this, as explained in the pipeline components documentation.
If you want GROQ to omit null/undefined values (which it sounds like you do), you can add a filter using the defined() function:
*[_type == "internalCustomers" && 'myMail@mail.com' in users[]->email]{
"totalHours": tasks[].tasks[defined(usedTime)].usedTime
}This filters the inner tasks array to only include items where usedTime is defined before extracting the values.
Looking at your attempts:
tasks[].tasks->usedTime - The -> operator is for following references, not accessing propertiestasks[].tasks[]->usedTime - Same issue with ->tasks[].tasks[]->.usedTime - Same reference operator issuetasks[].tasks.usedTime - Missing the second [] to properly iterate through the nested arrayThe correct syntax for accessing properties in nested arrays is to use [] for each array level, then access the property directly with dot notation. The -> operator is specifically for dereferencing document references, not for property access.
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