Loading TOC...

MarkLogic Server 11.0 Product Documentation
AccessPlan.prototype.joinDocCols

AccessPlan.prototype.joinDocCols(
   cols as Object?,
   $sourceCol as Object
) as ModifyPlan

Summary

This function populates the view with the uri, doc, collections, metadata, permissions, and / or quality document descriptor columns for database document values.

Parameters
cols Supplies a document column identifier object to specify which document columns to join and their names. The names cannot conflict with existing column names. To use the default column names, use op.docCols or a null value.
$sourceCol The source column to join. This is either an op.fragmentIdCol object specifying a fragment id column or a op.col, op.viewCol or op.schemaCol that contains document uris. Joining on a fragment id is more efficient than joining on an uri column.

Usage Notes

joinDocCols is a method of the following classes:

Example

const op = require('/MarkLogic/optic');
const docColIdentifier =
      {uri: 'newUri',
       doc:'newDoc',
       collections:'newCollections',
       metadata:'newMetadata',
       permissions:'newPermissions',
       quality:'newQuality'}
op.fromDocUris(cts.wordQuery('tiger', ['case-sensitive']))
  .joinDocCols(docColIdentifier, op.fragmentIdCol('fragmentId'))
  .orderBy('newUri')
  .result();

/* If you have a document in database which contains word 'tiger', above query returns
{"uri":"/optic/1.json",
"newUri":"/optic/1.json",
"newDoc":{"desc":"tiger"},
"newCollections":["fromDocDescriptor", "write"],
"newTemporalCollection":null,
"newPermissions":[{"capability":"update", "roleId":"15520654661378671735"}, {"capability":"read", "roleId":"7089338530631756591"}],
"newMetadata":{"startData":"2014-04-03T11:00:00", "endDate":"9999-12-31T11:59:59Z"},
"newQuality":1}
*/
  

Example

const op = require('/MarkLogic/optic');
op.fromDocUris(cts.wordQuery('tiger', ['case-sensitive']))
  .joinDocCols({doc:'doc'}, op.col('uri'))
  .orderBy('uri')
  .result();

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

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'))
  .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

const op = require('/MarkLogic/optic');
op.fromDocUris(cts.wordQuery('tiger', ['case-sensitive']))
  .joinDocCols(null, op.fragmentIdCol('fragmentId'))
  .orderBy('uri')
  .result();

/* If you have a document in database which contains word 'tiger', above query returns
{"uri":"/optic/1.json",
"doc":{"desc":"test1"},
"collections":["fromDocDescriptor", "write"],
"metadata":{"startData":"2014-04-03T11:00:00", "endDate":"9999-12-31T11:59:59Z"},
"permissions":[{"capability":"update", "roleId":"15520654661378671735"}, {"capability":"read", "roleId":"7089338530631756591"}],
"quality":1}
*/
  

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