Loading TOC...

MarkLogic 12 EA 1 Product Documentation
op.fromDocDescriptors

op.fromDocDescriptors(
   docsDescriptor as Object[],
   [qualifier as String?]
) as ModifyPlan

Summary

This function constructs document rows from the docsDescriptors.

Parameters
docsDescriptor An array of document descriptors. Each document descriptor describes a document. A document descriptor contains a combination of uri, doc, collections, metadata, permissions, quality and temporalCollection. This is a simpler form of op.fromParam.
qualifier Specifies a name for qualifying the column names.

See Also

Example

const op = require('/MarkLogic/optic');
const docsDescriptor = [
  {uri:'test1.json',
   doc:{"desc":"test1"},
   collections:['fromDocDescriptor', 'optic'],
   metadata:{'meta':'value1'},
   permissions:[xdmp.permission("rest-reader","read"),xdmp.permission("rest-writer","update")],
   quality:1,
   temporalCollection:'update'}
];
op.fromDocDescriptors(docsDescriptor).result();
  

Example

declareUpdate();
const op = require('/MarkLogic/optic');
const docsDescriptor = [
  {uri:'/optic/update/joinDocDescriptors1.json',
   doc:{"desc":"test1"},
   collections:['fromDocDescriptor', 'write'],
   metadata:[{'validStart': "2014-04-03T11:00:00", 'validEnd': "9999-12-31T11:59:59Z"}],
   permissions:[xdmp.permission("rest-reader","read"),xdmp.permission("rest-writer","update")],
   quality:1
  },
  {uri:'/optic/update/joinDocDescriptors2.json',
   doc:{"desc":"test2"},
   collections:['fromDocDescriptor', 'write'],
   metadata:[{'validStart': "2014-04-03T11:00:00", 'validEnd': "9999-12-31T11:59:59Z"}],
   permissions:[xdmp.permission("rest-reader","read"),xdmp.permission("rest-writer","update")],
   quality:2
  },
];
op.fromDocDescriptors(docsDescriptor)
  .write()
  .result();
  

Example

//Performs a join of op.fromDocDescriptors and op.fromLiterals
//It returns
//{"left.doc":{"desc":"test0"}, "right.val":0, "left.uri":"/test/optic/0.json", "right.uri":"/test/optic/0.json"}
//{"left.doc":{"desc":"test5"}, "right.val":5, "left.uri":"/test/optic/5.json", "right.uri":"/test/optic/5.json"}

const op = require('/MarkLogic/optic');
const docsDescriptor = [
    {uri:'/test/optic/0.json', doc:{"desc":"test0"}},
    {uri:'/test/optic/1.json', doc:{"desc":"test1"}},
    {uri:'/test/optic/5.json', doc:{"desc":"test5"}}];
const fromDocDescriptors = op.fromDocDescriptors(docsDescriptor, 'left');
const fromLiteral = op.fromLiterals([
            {uri:'/test/optic/0.json', val:0},
            {uri:'/test/optic/5.json', val:5}
            ], 'right')
fromDocDescriptors
  .joinInner(fromLiteral)
  .where(
      op.eq(
           op.viewCol('left', 'uri'),
           fromLiteral.col('uri')
           )
      )
  .orderBy(op.viewCol('left','uri'))
  .result();
  

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