Hi Eliot,
additionally to Dirk's hint, I'd like to point you to our DBA RESTXQ code. It contains many examples on how to perform updates exclusively with the BaseX extensions of XQuery.
Best, Christian
On Sat, Jul 11, 2015 at 7:38 PM, Eliot Kimber ekimber@contrext.com wrote:
In my link management application I'm trying to refactor my code to move my link management metadata out of the content database (the one that otherwise has the user's XML docs) and into a separate database.
The problem I'm running into is that because db:create() is put last on the pending updates list, you can't do
return ( db:create('new-database'), db:add('new-database', '<some-data/>'))
There doesn't seem to be a direct way through the RESTXQ-managed application to create the database since updating functions don't return anything (so I can't, for example, have the root page handler ensure that the database is there simply by calling an XQuery function to initial it).
I think the only solutions are:
- Have the database creation managed outside the REST application (e.g.,
in my git hooks, which are where the content database creation is done)
- Use the redirect technique so that, for example, the root page is
handled by an updating function that does the database initialization and then returns a redirect to the real root page handler.
Have I missed an option?
Thanks,
Eliot
Eliot Kimber, Owner Contrext, LLC http://contrext.com