Loading TOC...

MarkLogic Server 11.0 Product Documentation
op.rollup

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

Summary

This function specifies a list of grouping keys for a group and returns that group and larger groups (including all rows) formed by dropping columns from right to left. 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.rollup(['Category', 'Location'])
  

produces the same groups as the following calls

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

Example

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

op.fromView('main', 'expenses')
   .groupByUnion(
       op.rollup(['Category', 'Location']),
       op.sum("TotalAmount", "Amount")
       )
   .orderBy(['Category', 'Location'])
   .result();
  

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.