hi, My objective is to delete the collections/files through the DELETE request using HTTP module. The DELETE operation does fine, when I ran it from BasexGUI. But if i put the same query inside delete.xq and invoke it by http://localhost:8984/rest?run=delete.xq, The request never returns any response and possibly got hanged. I need to restart the database to make the database to function.
I am enclosing the xq i used,
import module namespace http='http://expath.org/ns/http-client';
declare function local:cleanlist() { ('sample/record1','sample/record2','sample/record3') };
declare function local:cleandb() { try { for $cl in local:cleanlist() return http:send-request(<http:request method="DELETE" href="http://localhost:8984/rest/%7B$cl%7D" status-only = "true" username = "admin" password = "admin" send-authorization="true"> </http:request>)
} catch err { err:description } };
<cleandb>{ local:cleandb() }</cleandb>
Hi Seenivasan,
updating REST requests should never be executed on the same machine, otherwise you will run into deadlocks or end up with corrupt data. Instead, you should use XQuery Update to directly delete the nodes or databases in question. This could e.g. look as follows:
let $db := "sample" for $cl in ("record1", "record2", "record3") return db:delete($db, $path)
You'll find some more information on XQuery Update in our documentation.
Hope this helps, Christian
[1] http://docs.basex.org/wiki/XQuery_Update ___________________________
My objective is to delete the collections/files through the DELETE
request using HTTP module. The DELETE operation does fine, when I ran it from BasexGUI. But if i put the same query inside delete.xq and invoke it by http://localhost:8984/rest?run=delete.xq, The request never returns any response and possibly got hanged. I need to restart the database to make the database to function.
I am enclosing the xq i used,
import module namespace http='http://expath.org/ns/http-client';
declare function local:cleanlist() { ('sample/record1','sample/record2','sample/record3') };
declare function local:cleandb() { try { for $cl in local:cleanlist() return http:send-request(<http:request method="DELETE" href="http://localhost:8984/rest/%7B$cl%7D" status-only = "true" username = "admin" password = "admin" send-authorization="true"> </http:request>)
} catch err { err:description }
};
<cleandb>{ local:cleandb() }</cleandb> _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
basex-talk@mailman.uni-konstanz.de