Loading TOC...

MarkLogic Server 11.0 Product Documentation
ModifyPlan.prototype.select

ModifyPlan.prototype.select(
   columns as columnIdentifier[],
   [qualifier as String]
) as ModifyPlan

Summary

This call projects the specified columns from the current row set and / or applies a qualifier to the columns in the row set. Unlike SQL, a select call is not required in an Optic query.

Parameters
columns The columns to project from the input rows. 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.
qualifier Specifies a name for qualifying the column names in place of the combination of the schema and view names. Use cases for the qualifier include self joins. Using an empty string removes all qualification from the column names.

Usage Notes

select is a method of the following classes:

See Also

Example

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

op.fromView('main', 'employees')
   .select(['EmployeeID', 'FirstName', 'LastName'])
   .result();
  

Example

// Return all of the expenses and expense categories 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 Plan =
employees.joinInner(expenses, op.on(employees.col('EmployeeID'), expenses.col('EmployeeID')))
   .select([employees.col('EmployeeID'), 'FirstName', 'LastName', expenses.col('Category'), 'Amount'])
   .orderBy(employees.col('EmployeeID'))

   Plan.result();
  

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