Why GROQ?
The datastore is the most important part of what defines Sanity. Sanity is built for structured content, which is richer than simple two-dimensional tables. Likewise, GROQ is meant to be more powerful and easier to use than traditional SQL, used to query a database. GROQ stands for Graph Oriented Query language, so, as the name suggests, it is a query language used to query graphs, which are able to represent more complex data structures.
GROQ has four main features:
- Expressive filtering: This allows us to build the query using a speakable syntax. If we are looking for a
venue
within our venues namedWill's Pub
, then we will simply use the following expression, which equates to where thetype
isvenue
and the (venue
) name isWill's Pub
:_type== "venue" && name=="Will's Pub"
- Joins: GROQ can join together several documents, combining the result together.
- Shaping: You can decide which content fields to include or also...