Hi Deepak,
Look in the Modules, not the Admin folder. Here is a typical case taken from
triggers.xqy:
define function
get-unique-trigger-id()
as xs:unsignedLong
{
let $col := triggers-collection(),
$attempt := xdmp:random(),
$doc-uri := fn:concat(triggers-uri(), xs:string($attempt)),
$docs := for $d in fn:collection($col) return fn:base-uri($d)
return
if ($doc-uri = $docs)
then get-unique-trigger-id()
else $attempt
}
You can make it slightly more robust by counting the attempts and throwing an
error if you need to many attempts. The number of unique numbers generated by
xdmp:random is large though, so that is only necessary when you have good
reason to believe that you could approach that limit..
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
P Please consider the environment before printing this mail.
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
> deepak mohan
> Sent: zondag 28 maart 2010 17:44
> To: [email protected]
> Subject: [MarkLogic Dev General] Unique key construction
>
> Hi All,
>
> Please tell me how ML constructs the unique ID while creating
> any ML entities(App Servers, DB, forest etc.). I need to
> generate a unique ID. I tried dig into the ML Admin modules
> APi, I couldnot find the algo. Are they using random() and
> check for existence?
>
> Thanks,
> Deepak Mohanakrishnan.
>
>
> ________________________________
>
> Your Mail works best with the New Yahoo Optimized IE8. Get it
> NOW!
> <http://in.rd.yahoo.com/tagline_ie8_new/*http://downloads.yaho
> o.com/in/internetexplorer/> .
>
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general