MarkLogic 9 Product Documentation
flexrep.configurationTargetSetFilterOptions

flexrep.configurationTargetSetFilterOptions(
   cfg as element(flexrep.configuration),
   target-id as (Number|String),
   val as element(flexrep.filterOptions)
) as element(flexrep.configuration)

Summary

This function sets the specified filter options for this replication configuration. The options specified in the val parameter are passed to the xdmp.invoke of the filter module, so any of the options you would specify in the xdmp.eval function are recognized.

Parameters
cfg The replication configuration.
target-id The ID of the replication target.
val Options to apply when invoking an outbound filter module. Specify the options as an XML element named filter-options in the "flexrep" namespace. The options element can contain any of the options from xdmp.invoke. The option child elements from xdmp:invoke must be in the "xdmp:eval" namespace.

Example

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

  declareUpdate();
  // 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 config = flexrep.configurationGet(domain, true);
  const targetId = flexrep.configurationTargetGetId(config, 'Replica');

  const filterOpts =
     fn.head(xdmp.unquote('<flexrep:filter-options xmlns:flexrep="http://marklogic.com/xdmp/flexible-replication">' +
       '<user-id xmlns="xdmp:eval">{xdmp:user("John")}</user-id>' +
     '</flexrep:filter-options>')).root;


  let cfg = 
    flexrep.configurationTargetSetFilterOptions(
       config, 
       targetId, 
       filterOpts);

  flexrep.configurationInsert(cfg); 
  
  // Sets the filter user to "John".
   
Powered by MarkLogic Server | Terms of Use | Privacy Policy