trgr.triggersChangeModulesDatabase( old-db as xs.anyAtomicType, new-db as xs.anyAtomicType ) as null
Any Trigger with a module referring to $old-db will be updated to refer to $new-db. This is useful after restoring a Trigger's database to a different cluster with different database IDs than the one from which it was backed up.
Parameters | |
---|---|
old-db | The old database ID or name. |
new-db | The new database ID or name. |
xquery version "1.0-ml"; (: run this against your triggers database :) import module namespace trgr = "http://marklogic.com/xdmp/triggers" at "/MarkLogic/triggers.xqy"; trgr:triggers-change-modules-database(xdmp:database("Triggers"), xdmp:database("Modules")) => Empty sequence. All triggers referencing the "Triggers" database by name or by ID will have their modules database set to reference the ID of the Modules database. trgr:triggers-change-modules-database("Triggers", "Modules") => Empty sequence. All triggers referencing the "Triggers" database by name or id ( meaning Triggers with a module referencing the ID of Triggers database will be affected too) as their modules database will be changed to reference the Modules database.
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: Get the most useful answers to questions from the MarkLogic community, or ask your own question.