
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYes! You can retrieve a list of all unique document types (_type values) from your Content Lake using GROQ. Here's how:
*[]._typeThis returns an array of all _type values from all documents. However, you'll likely want to get just the unique types without duplicates:
array::unique(*[]._type)This uses the array::unique() function to filter out duplicate _type values, giving you a clean list of all schema types that actually exist in your dataset.
If you want more information about each type, you could count how many documents of each type exist:
{
"types": array::unique(*[]._type)
}Or create a more detailed breakdown by grouping and counting. While GROQ doesn't have a built-in GROUP BY, you can work around it:
array::unique(*[]._type) | order(@) {
"type": @,
"count": count(*[_type == ^])
}You can test these queries in:
sanity.imageAsset and sanity.fileAsset if you have uploaded assetsThe array::unique() function is perfect for this use case - it removes duplicates from arrays, which is exactly what you need when getting all unique _type values from your documents!
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