By default all functions invoked by XQRS are executed in
read only mode.
You can change the transaction type of the function by adding the
%xdmp:update
annotation,
which will set the transaction type to "update".
Consider the following set of functions, only the last function
get
is a read-only function.
declare
%rest:path("/my-stuff/insert/{$uri}")
%xdmp:update
function insert($uri as xs:string) {
xdmp:document-insert($uri, <e>{$uri}</e>)
};
declare
%rest:path("/my-stuff/delete/{$uri}")
%xdmp:update
function delete($uri as xs:string) {
xdmp:document-delete($uri)
};
declare
%rest:path("/my-stuff/get/{$uri}")
function get($uri as xs:string) {
fn:doc($uri)
};
%xdmp:update
annotation (i.e. from one of your own functions) this won't
change the current transaction type.
It must be directly invoked from the XQRS framework in order
for the transaction type to be upgraded to an update
transaction.