Wiki source for MarkLogicExists

Show raw source

======Mark Logic Command: exists======
Detects if a document exists on a Mark Logic server

exists [-c uri|-connect uri] document

Checks to see if a document exists on the MarkLogic server.

||-c,-connect uri||Use the connection string instead of $MLCONNECT||
||document|| uri of the document to test||

Assuming the prefix "ml" is imported as the marklogic module, tests to see if the directory /test/test.xml exists

if ml:exists /test/test.xml ; then
echo /test/test.xml exists
echo /test/test.xml doesnt exist

Example, safely delete /test/test.xml only if it exists

ml:exists /test/test.xml && ml:del /test/test.xml

To check if directory exists use [[MarkLogicDirexists direxists]]

exists is implemented as an xsh script which simply calls exists(doc(uri)). The source of the script is

# return true if document exists else return false
_opts=$<(xgetopts -a -p "c=connect:,t=text" -ps -- "$@")
shift $?

:query $_opts -b -q <{{
declare variable $uri external ;
}}> -v uri $1

[[ModuleMarkLogic MarkLogic Extension Module]]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki