MarkLogic 10 Product Documentation
alert:create-triggers

alert:create-triggers(
   $uri as xs:string,
   $events as element(trgr:data-event)*
) as xs:unsignedLong*

Summary

Create triggers that invoke the standard alerting trigger module. The caller must have the alert-admin privilege. The returned trigger IDs must be associated with the config using alert:config-set-trigger-ids and then saving the updated config with alert:config-insert .

Parameters
uri The URI specified to alert:make-config .
events Events for which to create triggers.

Example

  xquery version "1.0-ml";
  import module namespace alert = "http://marklogic.com/xdmp/alert" 
       at "/MarkLogic/alert.xqy";
  import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

  let $uri := "http://acme.com/alert/message-board"
  let $trigger-ids :=
    alert:create-triggers (
        $uri,
        trgr:trigger-data-event(
            trgr:directory-scope("/", "infinity"),
            trgr:document-content(("create", "modify")),
            trgr:pre-commit()))
  let $config := alert:config-get($uri)
  let $new-config := alert:config-set-trigger-ids($config, $trigger-ids)
  return alert:config-insert($new-config)
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy