Loading TOC...

MarkLogic Server 11.0 Product Documentation
op.docCols

op.docCols(
   [qualifier as String?],
   [names as String[]]
) as docColsIdentifier

Summary

Constructs a document column identifier object for columns of uri, doc, collections, metadata, permissions, quality and temporalCollection. The document column identifier object can be passed to the prototype.joinDocCols or prototype.write .

Parameters
qualifier Specifies a name for qualifying the column names.
names An array of columns names, a combination of uri, doc, collections, metadata, permissions, quality and temporalCollection.

Example

const op = require('/MarkLogic/optic');
op.fromDocUris(cts.wordQuery('tiger', ['case-sensitive']), 'A')
  .joinDocCols(op.docCols('A', ['uri', 'doc', 'collections']), op.viewCol('A','uri'))
  .orderBy(op.viewCol('A','uri'))
  .result();

/* If you have a document in database which contains word 'tiger', above query returns
{"A.uri":"/optic/1.json",
"A.doc":{"desc":"tiger"},
"A.collections":["fromDocDescriptor", "write"]}
}
*/
  

Example

// Overwrite document collections
declareUpdate();
const op = require('/MarkLogic/optic');
const docsDescriptor = [
  {uri:'/optic/update/write1.json', collections:['overwrite', 'overwrite10']},
  {uri:'/optic/update/write2.json'},
  {uri:'/optic/update/write3.json', collections:Sequence.from(['overwrite', 'overwrite12'])}
];
op.fromDocDescriptors(docsDescriptor)
  .orderBy('uri')
  .write(op.docCols(null, ['uri', 'doc', 'collections']))
  .result();
  

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