Loading TOC...

flexrep.pullCreate

flexrep.pullCreate(
   name as String,
   domain-id as (Number|String),
   target-id as (Number|String),
   urls as String[],
   http-options as element(flexrep.httpOptions)?
) as element(flexrep.pull)

Summary

This function creates a configuration on a Replica database to pull updates from the Master database. If a configuration already exists for the given target and domain IDs, then the configuration is overwritten.

Parameters
name The name of the pull configuration.
domain-id The ID of the domain containing the replicated content. This value is obtained from the Trigger database used by the Master database.
target-id The ID of the replication target. This value is obtained from the Master database.
urls The URL of the Master App Server.
http-options The HTTP options in XML format.

Example

// This query must be executed on a Replica database.
const flexrep = require('/MarkLogic/flexrep');

    declareUpdate();
    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.configurationCreate(domain);
  const cfg = flexrep.configurationGet(domain, true);

  // Specify the ID of the replicated CPF domain obtained from the Master's 
  //    Triggers database. 
  const domainId = flexrep.configurationGetId(cfg);

  // Specify the ID of the replication target obtained from the Master database. :)
  const targetId = flexrep.configurationTargetGetId(cfg, 'NewReplica');

  // Specify the HTTP options for the replication target.
  const httpOptions = fn.head(xdmp.unquote(
    '<flexrep:http-options xmlns:flexrep="http://marklogic.com/xdmp/flexible-replication">' +
      '<http:authentication xmlns:http="xdmp:http">' +
        '<http:username>replicator</http:username>' +
        '<http:password>admin</http:password>' +
      '</http:authentication>' +
    '</flexrep:http-options>')).root;

  const pullConfig = flexrep.pullCreate(
    "Master",
      domainId,
        targetId,
        "http://localhost:8015/",
          httpOptions);

  // Insert the pull configuration into the Replica database.
  flexrep.pullInsert(pullConfig); 

  // Creates a pull replication configuration element for the specified domain.
   

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