dba/databases
library moduleRA
Summary
Query resources.
- Tags
Author: Christian Grün, BaseX Team 2005-21, BSD License
__source : databases/resources/db-query.xqm
Imports
This module is imported by 0 modules. It imports 1 modules.
Variables
None
Functions
4.1 dba:db-query
Arities: dba:db-query#3RA
dba:db-query
(
$name
as
xs:string
, $resource
as
xs:string
, $query
as
xs:string
)
as
xs:string
- name
as
xs:string
name of database - resource
as
xs:string
resource - query
as
xs:string
query
xs:string
result string
Invokes 2 functions from 2 modules
- util:query#2
- {http://basex.org/modules/db}open#2
Invoked by 0 functions from 0 modules
Annotations
%rest:POST | ('{$query}') |
%rest:path | ('/dba/db-query') |
%rest:query-param | ('name','{$name}') |
%rest:query-param | ('resource','{$resource}') |
%rest:single | () |
%output:method | ('text') |
Source ( 7 lines)
function dba:db-query(
$name as xs:string,
$resource as xs:string,
$query as xs:string
) as xs:string {
util:query(if($query) then $query else '.', db:open($name, $resource))
}
Namespaces
The following namespaces are defined:
Prefix | Uri |
---|---|
dba | dba/databases 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
output | http://www.w3.org/2010/xslt-xquery-serialization |
rest | http://exquery.org/ns/restxq |
util | dba/util |
Source Code
(:~
: Query resources.
:
: @author Christian Grün, BaseX Team 2005-21, BSD License
:)
module namespace dba = 'dba/databases';
import module namespace util = 'dba/util' at '../../lib/util.xqm';
(:~
: Runs a query on a document and returns the result as string.
: @param $name name of database
: @param $resource resource
: @param $query query
: @return result string
:)
declare
%rest:POST('{$query}')
%rest:path('/dba/db-query')
%rest:query-param('name', '{$name}')
%rest:query-param('resource', '{$resource}')
%rest:single
%output:method('text')
function dba:db-query(
$name as xs:string,
$resource as xs:string,
$query as xs:string
) as xs:string {
util:query(if($query) then $query else '.', db:open($name, $resource))
};