Hello Eliot,
You can add the documents directly using the db:create() function, thus being able to create and initialize the database. If you have multiple documents to add it can be done like the following example:
db:create('new-database', (<some-data/>, <more-data/>), ("somedata.xml", "moredata.xml"))
Hope this helps, Dirk
On 07/11/2015 07:38 PM, Eliot Kimber 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