MarkLogic 10 Product Documentation
PreparePlan.prototype.generateView

PreparePlan.prototype.generateView(
   schemaName as String,
   viewName as String,
   [columnDeclarations as object[]]
) as ElementNode

Summary

This method generates a view that encapsulates a query. Insert the generated XML into the schemas database and then use the op.fromView op:from-view accessor to use the generated view.

Parameters
schemaName The schema name that can be passed to op.fromView() when accessing the generated view.
viewName The view name that must be passed to op.fromView() when accessing the generated view.
columnDeclarations Optional type and nullability declarations for some or all of the columns of the view.

Usage Notes

Each column must have an atomic data type that is indexable by TDE. The unqualified name of each column must be unique in the row. The optional column declarations takes the following keys to specify the treatment of rows with invalid values:

generateView is a method of the following classes:

Example

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

op.fromView('main', 'employees')
   .where(cts.collectionQuery('/division/manufacturing'))
   .select(['EmployeeID', 'FirstName', 'LastName'])
   .orderBy('EmployeeID')
   .generateView('main', 'manufacturingEmployees');
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy