MarkLogic 12 EA 1 Product Documentation
ModifyPlan.prototype.orderBy

ModifyPlan.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();

  
Powered by MarkLogic Server | Terms of Use | Privacy Policy