op.cube

op.cube(
   columns as columnIdentifier[]
) as groupdef+

Summary

This function specifies a list of grouping keys for a group and returns that group and every possible larger group (including all rows) formed from any subset of keys. The result is used for building the first parameter for the prototype.groupByUnion or prototype.groupToArrays functions.

Parameters
columns The columns to use as grouping keys. The columns can be named with a string or a column parameter function such as op.col or constructed from an expression with op.as.

Usage Notes

The following call

       op.cube(['Category', 'Location'])
  

produces the same groups as the following calls

       [op.group(['Category', 'Location']),
        op.group('Category'),
        op.group('Location'),
        op.group()]
  

Example

const op = require('/MarkLogic/optic');

op.fromView('main', 'expenses')
   .groupByUnion(
       op.cube(['Category', 'Location']),
       op.sum("TotalAmount", "Amount")
       )
   .orderBy(['Category', 'Location'])
   .result();
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy