op.case( whenExpression as String, valueExpression as String ) as valueExpression
This function returns the specified valueExpression
if
the specified valueExpression
is true
.
Otherwise, it returns null.
Parameters | |
---|---|
whenExpression | One or more op.when expressions. |
valueExpression |
The value expression to return if none of the
op.when expressions is true .
|
const op = require('/MarkLogic/optic'); const employees = op.fromView('main', 'employees'); employees.select(['EmployeeID', op.as('cased', op.case([ op.when(op.eq(op.col('EmployeeID'), 2), 'second'), op.when(op.eq(op.col('EmployeeID'), 3), 'third')], 'otherwise'))]) .result();
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.