Loading TOC...

AccessPlan.prototype.select

AccessPlan.prototype.select(
   $columns as String,
   [$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 select.
$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:

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.