A how to guide to show you how to group query results using WOQL in TerminusDB and TerminusCMS
To use this How-To, first clone the Star Wars demo into your team on TerminusCMS. You will then have full access to the data needed for this tutorial
group_by
If we need to group variables according to some criteria, we can create an aggregate of solutions using group_by
.
A group by is composed of a focus, a template, and a group together with a query.
We will demonstrate this with the following query:
The first argument, here "eyes"
refers to the eyes variable, and is the variable around which to form the group, the focus.
The second ["label"]
is the template, which refers to the variable "label"
. The template will be those things grouped under the first variable.
The third variable v.group
, is the group variable, which will include groups of templates for each set of solutions which shares a focus.
This raw query output will be: