Loading TOC...

op:map

op:map(
   $plan as map:map,
   $mapper as function(item()) as item()*
) as map:map

Summary

This method applies the specified function to each row returned by the plan to produce a different result row.

Parameters
$plan The Optic Plan. You can either use the XQuery => chaining operator or specify the variable that captures the return value from the previous operation.
$mapper The function to be applied.

Example


xquery version "1.0-ml";

import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";

let $employees := op:from-view("main", "employees")
 
return $employees
   => op:order-by("EmployeeID")
   => op:map(function($row as map:map) {
             map:with($row, "seconds", floor(seconds-from-dateTime(current-dateTime())))
      })
   => op:result() 
  

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