Loading TOC...

MarkLogic 12 EA 2 Product Documentation
AccessPlan.prototype.orderBy

AccessPlan.prototype.orderBy(
   orderdef as String
) as ModifyPlan

Summary

This method sorts the row set by the specified order definition.

Parameters
orderdef The specified column or sortdef output from the op.asc or op.desc function.

Usage Notes

orderBy is a method of the following classes:

The library functions that return a sortdef used by the orderdef parameter are as follows:

Example

// Calculate the total expenses for each employee and return results in order of employee number.

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

const employees = op.fromView('main', 'employees');
const expenses = op.fromView('main', 'expenses');
const totalexpenses  = op.col('totalexpenses');
const Plan =
employees.joinInner(expenses, op.on(employees.col('EmployeeID'), expenses.col('EmployeeID')))
   .groupBy(employees.col('EmployeeID'), ['FirstName', 'LastName', expenses.col('Category'),
    op.sum(totalexpenses, expenses.col('Amount'))])
   .orderBy('EmployeeID')
Plan.result();

  

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