GroupBy Set operations

Aggregations are possible with Fauna Indexes and FQL, but by doing so we lose the ability to paginate through results. This is because we have to request one, large, page of data and then perform the aggregation steps afterward.

A GroupBy function could possibly aggregate over a Set based on the position of a tuple.

The following example has a lot of flaws, but I think is a starting point.

Paginate(
  GroupBy(
    Var("mySet"), // with shape [color, ref],
    0             // position of grouping variable in Index tuple
  )
)

{
  data: [
    [
      13,    // built in count?  default to sorting by count asc?
      "red", // value grouped on
      [ /* list of grouped tuples in their original form */ ]
    ],
    [
      42,
      "blue",
      [ /* list of grouped tuples in their original form */ ]
    ],
  ]
}