Loading TOC...


   paramName as String,
   qualifier as String?,
   rowColTypes as Object[]
) as ModifyPlan


This function constructs document rows with rows provided by a parameter.

paramName The paramName parameter specifies the placeholder parameter supplying the rows.
qualifier Specifies a name for qualifying the column names.
rowColTypes Describes the columns with an array of JavaScript objects. It's a combinations of column, type and nullable. The 'column' is the column name, which is required. The 'type' is the optional type of the column, which can be an atomic type or the default of none. The 'nullable' is an optional boolean defaulting to false. If your rows contains only uri, doc, collections, metadata, permissions, quality and temporalCollection columns, you could simply use op.docColTypes instead.

See Also


// It returns
// {"qualifier1.id":1, "qualifier1.firstName":"Jane", "qualifier1.lastName":"Woods"}
// {"qualifier1.id":2, "qualifier1.firstName":"Ken", "qualifier1.lastName":"First"}
const op = require('/MarkLogic/optic');
const rows =
  [{id: 1, firstName: 'Jane', lastName: 'Woods'},
   {id: 2, firstName: 'Ken', lastName: 'First'}];
const columnTypes   = [
      {"column":"id",        "type":"integer", "nullable":false},
      {"column":"firstName", "type":"string",  "nullable":true},
      {"column":"lastName",  "type":"string",  "nullable":true}];
op.fromParam("param", "qualifier1", columnTypes)
  .result("object", {"param":rows});


/* It returns

const op = require('/MarkLogic/optic');
const rows = [
    {uri:'/test/0.json', doc:{"desc":"test0"}},
    {uri:'/test/1.json', doc:{"desc":"test1"}},
    {uri:'/test/5.json', doc:{"desc":"test5"}}];
const fromParam = op.fromParam('param', 'left', op.docColTypes())
const fromLiteral = op.fromLiterals([
            {uri:'/test/0.json', val:0},
            {uri:'/test/5.json', val:5}
            ], 'right')
           op.viewCol('left', 'uri'),
  .result('object', {'param':rows});

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