op.toSource( exportedPlan as String ) as JavaScriptSource
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. |
// Generate the server-side JavaScript source for the exported plan, 'plan.json'. const op = require('/MarkLogic/optic'); op.toSource(cts.doc('plan.json'))
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')])