Hi folks,
I'm trying to implement a secure RESTXQ service like this:
declare %rest:path("api/users/init") %restxq:PUT("{$data}") %output:method("text") function page:init-user($data) {
sec:secure(function() { let $profile := json:parse-ml(convert:binary-to-string($data)) return ( insert node attribute id { sec:get-current-user-id() } into $profile, insert node $profile as last into db:open("db")/s:root ) }) };
And I have two problems:
- when executing it like this, inside of a closure, nothing happens. No modifications of the database and no errors (%updating missing) either - which is weird. Is this construct supported in 7.5?
- when I remove the sec:secure call and leave only the rest (adding %updating to the declaration) the second insert runs but the first one doesn't - the node is saved without a "id" attribute. Does this have something to do with the PUL order? (http://docs.basex.org/wiki/Update#Example)
Thanks for your hints! I feel like I'm overlooking something obvious... Daniel
-- danielkvasnicka.net