Stéphane,

Adding a collection to a document is actually a change to the document. The 
"collection" works very much like an invisible element added to the document - 
the collection does not exist as a separate entity outside these tags added to 
the documents.

Can you tell us what you are trying to accomplish? When possible, I prefer not 
to use triggers and instead build sensible data services that allow full 
control of the updates. In that case, your update-content.xqy module would 
invoke the functionality you want, but your add-to-collection.xqy module would 
not, without using triggers in either case.

Yours,
Damon

--
Damon Feldman
Sr. Principal Consultant, MarkLogic

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Stephane Toussaint
Sent: Friday, February 08, 2013 9:12 AM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Triggers Handling : Directory scope constraint 
and collection

Hi,

With a trigger defined as in the current Api Documentation 
(trgr:create-trigger())

> xquery version "1.0-ml";
> import module namespace trgr="http://marklogic.com/xdmp/triggers"; at 
> "/MarkLogic/triggers.xqy";
> 
> trgr:create-trigger(
>       "myTrigger",
>       "Simple trigger example", 
>       trgr:trigger-data-event(
>               trgr:directory-scope("/myDir/", "1"),
>               trgr:document-content("modify"),
>               trgr:post-commit()
>       ),
>       trgr:trigger-module(xdmp:database("test"), "/modules/", "log.xqy"),
>       fn:true(),
>       xdmp:default-permissions()
> )


If a change is change is done on a document under 'myDir' directory, then the 
modules log.xqy is triggered. This is just fine.
But if we add any of these documents to a collection (any collection), this 
trigger is handle too. 

I don't understand why ? Adding a document to a collection doesn't change the 
document content. This just some kind of metadata.
Why doesn't collection acts as properties for this use case ? Adding a property 
to a collection doesn't handle the trigger. And if you wan't so, then use 
trgr:property-content constraint.

The problem is that when the module is triggered I can't guess if it is because 
content update (the case I wan't to work on) or if someone just add this 
document to a collection (I don't care for this use case).

Could someone provide me information on this case ?

Thanks
Stéphane




_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to