Loading TOC...

flexrep.configurationTarget

flexrep.configurationTarget(
   cfg as element(flexrep.configuration),
   target-id as (Number|String),
   [assert as Boolean]
) as element(flexrep.target)?

Summary

This function returns a specified target for a configuration, or throws an error if it does not exist.

Parameters
cfg The replication configuration.
target-id The target ID.
assert Set to true to throw an exception if the configuration does not exist. The default value is false.

Example

const flexrep = require('/MarkLogic/flexrep');

  //Obtain the domain ID from the database used by the Master to enable CPF.
  const domain = xdmp.eval(
    'const dom = require("/MarkLogic/cpf/domains");' +
      'fn.data(dom.get("Default Master").xpath("//dom:domain-id"));',
       null,
         {
          'database' : xdmp.database('Triggers')
         });

  const cfg = flexrep.configurationGet(domain, true);
  const targetId = flexrep.configurationTargetGetId(cfg, 'Replica');

  flexrep.configurationTarget(cfg, targetId, true);

  // Returns the configuration for the 'Replica' target.    
   

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