Loading TOC...

MarkLogic Server 11.0 Product Documentation
op.toSource

op.toSource(
   exportedPlan as String
) as JavaScriptSource

Summary

This function generates a server-side JavaScript source code representation of a plan from the JSON or JavaScript literal object representation of a plan that was exported by the prototype.export function.

For more information, see Exporting and Importing a Serialized Optic Query in the Application Developer's Guide

Parameters
exportedPlan The exported plan. This is generated by the prototype.export function.

Example

// Generate the server-side JavaScript source for the exported plan, 'plan.json'.

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

op.toSource(cts.doc('plan.json'))
  

Example

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

const EmployeePlan =
   op.fromView('main', 'employees')
     .select(['EmployeeID', 'FirstName', 'LastName'])
     .orderBy('EmployeeID')
const planObj = EmployeePlan.export();
   op.toSource(planObj)

=>

op.fromView('main', 'employees', null, null)
  .select([op.col('EmployeeID'), op.col('FirstName'), op.col('LastName')], null)
  .orderBy([op.col('EmployeeID')])
  

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