Hi Utsav, It would be a bit easier if you would store versions and latest copy in the same database. In fact, the dls library should facilitate thiswithout needing you to code much yourself. On the other hand, if the database is accessed through webdav, you will need triggers or CPF to make sure previous copies are preserved (in same or other database).
To answer your question: you can add triggers to your source database. There are different trigger events for new inserts, updates and deletes, as well as for database startup. You will need xdmp:eval, xdmp:spawn or xdmp:invoke with external variables (to pass the document) and explicit database setting to be able to access a documents database other than the one connected to the current app server. More details on triggers, dls, and eval can be found here: http://developer.marklogic.com/pubs/4.1/apidocs/Triggers.html http://developer.marklogic.com/pubs/4.1/apidocs/dls.html http://developer.marklogic.com/pubs/4.1/apidocs/Ext-6.html You might already have found it, but chapter 17 of the dev-guide explains the concepts of Triggers, and also provides some examples: http://developer.marklogic.com/pubs/4.1/books/dev_guide.pdf Kind regards, Geert > drs. G.P.H. (Geert) Josten Consultant Daidalos BV Hoekeindsehof 1-4 2665 JZ Bleiswijk T +31 (0)10 850 1200 F +31 (0)10 850 1199 mailto:[email protected] http://www.daidalos.nl/ KvK 27164984 De informatie - verzonden in of met dit e-mailbericht - is afkomstig van Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend. > From: [email protected] > [mailto:[email protected]] On Behalf Of > Joshi, Utsav (LNG-CON) > Sent: woensdag 14 juli 2010 16:52 > To: General Mark Logic Developer Discussion > Subject: [MarkLogic Dev General] Loading document from one ML > database to another ML database > > Hi, > > I have 2 Marklogic databases and in one ML database (source > database) I am maintaining the latest version of documents(it > is getting getting continuous updates). > I want to load latest document into second Marklogic database > (whenever it is updated). > I want to load it as new version if it already exists > otherwise create initial version. > > I want to do it through XQueries (I looked at recordloader > briefly but I don't want to use XCC) How will I know if there > is new document available in source database(should I use > triggers or reverse query) > > Can you please point me to documentation available for my questions. > > With Regards. > > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
