Loading TOC...

trgr.triggersChangeModulesDatabase

trgr.triggersChangeModulesDatabase(
   old-db as (Number|String),
   new-db as (Number|String)
) as null

Summary

This function changes the trigger definitions of each trigger definition in the database that has the database ID $old-db and replaces each database ID with $new-db. This is useful after restoring a triggers database to a different cluster that has different database IDs than the one from which it was backed up.

Parameters
old-db The old database ID.
new-db The new database ID.

Example

xquery version "1.0-ml"; 

(: run this against you triggers database :) 
import module namespace trgr = "http://marklogic.com/xdmp/triggers" 
      at "/MarkLogic/triggers.xqy";

trgr:triggers-change-modules-database(5184170867299910410, 
      xdmp:database("Modules") )
      
=> Empty sequence. Sets all triggers that reference 5184170867299910410
    as their modules database to reference the ID of the Modules database.
    

Example

declareUpdate();
const trgr = require('/MarkLogic/triggers');

trgr.triggersChangeModulesDatabase(5184170867299910410, 
      xdmp.database('Modules'));
      
// Empty sequence. Sets all triggers that reference 5184170867299910410
// as their modules database to reference the ID of the Modules database.
   

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