A RESTXQ definition could look something like this:

declare
    %rest:path("/a/{$client}/{$path}")
function yourmodule:test($client as xs:string, $path as xs:string) {
    let $db := switch ($client)
        case "clientA" return db:open("dbA")
        case "clientA" return db:open("dbA")
        default return db:open("dbX")
    return yourmodule:do-something-with($db, $path)
};

And the called function do-something-with could also depend on the client


Am 21.02.2020 um 03:48 schrieb DYER Chris:

Hi Markus,

Our intent is to use REST and RESTXQ interfaces to interact with data on a single database using some server side XQueries.

 

However, we may have 2 (or more) databases provided by some server, and associated xqueries are specific to the contents of each database (as the contents of each of these databases may be structured differently).

 

We would like for a client to be able to open a single database and be able to run associated XQueries, without requiring client side knowledge of which server side xqueries are associated with the database it has opened.

 

Does this help describe what we are trying to achieve?

 

Cheers,
Chris

 

 

From: BaseX-Talk <basex-talk-bounces@mailman.uni-konstanz.de> On Behalf Of Markus Wittenberg
Sent: Friday, 21 February 2020 12:08 PM
To: basex-talk@mailman.uni-konstanz.de
Subject: Re: [basex-talk] Database specific xquery modules

 

 Hi Chris,

as you might already know, BaseX has built-in REST support [1] which you can use to query and update data via HTTP. You can also use the RESTXQ [2] functionality to define arbitrary server side XQueries which can also be requested by HTTP and are also suitable for web applications. Both methods are not restricted to a single database.

Best regards,

  Markus

 

[1] http://docs.basex.org/wiki/REST

[2] http://docs.basex.org/wiki/RESTXQ

 

Am 21.02.2020 um 02:05 schrieb DYER Chris:

I am looking for some ideas on some architecture surrounding xquery modules.

 

Our situation is that we have multiple client applications in various languages that will connect to a database.

We will have some reasonably complex xqueries to extract data in certain structures that will be used by each of these clients.

So to avoid having to duplicate the query logic we would like the xqueries to reside "in" the database.

 

Additionally, we would like to use the same BaseX installation for multiple databases, corresponding to multiple projects.

The data in each of these databases may be against a different schema and our xqueries are essentially tied to the schema of the data. Thus, each database may need slightly different xqueries.

 

The xquery library modules looks to be global for the BaseX instance, as does the loading of main modules off of disk.

Is there any way to tie the query module or file to a specific database?

 

We are trying to avoid being limited to 1 database per BaseX instance.

 

An alternative would be to embed the xqueries within our client applications, but that involves duplication. Also, we are not sure if there are any performance difference with having the queries stored in the repo vs client side?

 

For background, we are looking at migrating from oracle to BaseX. So, we are effectively looking for an equivalent of multiple clients connecting to a userspace and using stored procedures which are specific to that userspace.

 

Any ideas on how to achieve this currently? Or is this something that BaseX could support?

 

Cheers,

Chris

 

-- 
Markus Wittenberg
 
Tel +49 (0)341 248 475 36
Mail wittenberg@axxepta.de
 
----
 
axxepta solutions GmbH
Lehmgrubenweg 17, 88131 Lindau
 
Amtsgericht Berlin HRB 97544B
Geschäftsführer: Karsten Becke, Maximilian Gärber
-- 
Markus Wittenberg

Tel +49 (0)341 248 475 36
Mail wittenberg@axxepta.de

----

axxepta solutions GmbH
Lehmgrubenweg 17, 88131 Lindau

Amtsgericht Berlin HRB 97544B
Geschäftsführer: Karsten Becke, Maximilian Gärber