AccessPlan.prototype.generateView( schemaName as String, viewName as String, [columnDeclarations as object[]] ) as ElementNode
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.
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:
name
: the unqualified name of the columntype
: the data type of the column (as specified in a TDE)collation
: the collation for a column with a string data type;
not allowed for other data typesnullable
: a boolean for whether the column can take null values (optional)invalidValues
:
the action (skip
or reject
defaulting to skip) taken when
a row has a value with the wrong data type or has a null for an unnullable column
generateView
is a method of the following classes:
const op = require('/MarkLogic/optic'); op.fromView('main', 'employees') .where(cts.collectionQuery('/division/manufacturing')) .select(['EmployeeID', 'FirstName', 'LastName']) .orderBy('EmployeeID') .generateView('main', 'manufacturingEmployees');
const op = require('/MarkLogic/optic'); const plan1 = op.fromLiterals([ {rowId: 1, colorIdShape: 1, desc: 'ball'}, {rowId: 2, colorIdShape: 2, desc: 'square'}, {rowId: 3, colorIdShape: 1, desc: 'box'}, {rowId: 4, colorIdShape: 1, desc: 'oval'}, {rowId: 5, colorIdShape: 5, desc: 'circle'} ]); const plan2 = op.fromLiterals([ {colorId: 1, colorDesc: 'red'}, {colorId: 2, colorDesc: 'blue'}, {colorId: 3, colorDesc: 'black'}, {colorId: 4, colorDesc: 'yellow'} ]); const output = plan1.joinInner( plan2, op.on(op.col('colorIdShape'), op.col('colorId')) ) .select(['rowId', op.as('description', op.col('desc')), 'colorId', 'colorDesc']) .orderBy(op.col('rowId')); output.generateView('ThreeParams', 'ThreeColsSelected', [{name:'rowId', type:'integer',nullable:true, invalidValues: 'reject'}, {name:'description', type:'string', invalidValues: 'reject'}, {name:'colorId', type:'integer',nullable:false, invalidValues: 'skip'}]);
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.