🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Calculating total documents in Sanity usage using GROQ queries

2 replies
Last updated: Jun 4, 2024
Hey hey!
Can I ask how “total documents” is calculated in Sanity usage?
I’m asking because I’m trying to replicate that number using a GROQ query, to keep track of our documents.

I end up with either too many, or too few, depending on how I’m counting.
For example, do total documents count across datasets?
May 31, 2024, 6:51 AM
would count all documents in a dataset. This, however, would count all system documents and assets. Those aren’t counted toward your quota. I think something along the lines of
count(*[_type in $types])
is an array of the document types you’ve defined in your schema should do it.
May 31, 2024, 4:39 PM
Thank you!
Jun 4, 2024, 9:47 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?