ModifyPlan.prototype.orderBy( orderdef as orderdef ) as ModifyPlan
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. The column can be named with a string or a column function such as op.col, op.viewCol, or op.schemaCol, or constructed from an expression with the op.as function. |
orderBy
is a method of the following classes:
The library functions that return a sortdef
used by the
orderdef
parameter are as follows:
// 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();
// 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 Plan = employees.select(['EmployeeID','FirstName','LastName','Salary']) .orderBy(op.asc(op.col('Salary'))) Plan.result();
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.