Skip to content

Instantly share code, notes, and snippets.

@tonyahowe
Created November 15, 2017 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonyahowe/a62e83b078a04aa7f2fcef1d48ba771b to your computer and use it in GitHub Desktop.
Save tonyahowe/a62e83b078a04aa7f2fcef1d48ba771b to your computer and use it in GitHub Desktop.
Where to put the console:log in this function?
declare function app:upload($node as node(), $model as map(*)) {
let $collection := '/db/apps/NiC/inReview/'
let $filename := request:get-uploaded-file-name('file')
(: make sure you use the right user permissions that has write access to this collection :)
let $login := xmldb:login($collection, 'public', 'public')
let $store := xmldb:store($collection, $filename, request:get-uploaded-file-data('file'))
(: I want to see what it's pulling for $filename--I'm getting a SAX prolog error, but there's nothing worrisome in the XML file I'm trying to upload :)
return
<results>
<message>File {$filename} has been stored at collection={$collection}.</message>
</results>
};
@peterstadler
Copy link

When using the console:log() function you'll have to import the module like

import module namespace console="http://exist-db.org/xquery/console";

at the top of your XQuery.

Then add e.g.

let $log := console:log($filename)

after let $filename … in line 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment