dba/databases  library module
RA

Summary

Query resources.
Tags

Author: Christian Grün, BaseX Team 2005-21, BSD License

__source : databases/resources/db-query.xqm

Related documents
ViewDescriptionFormat
xqdocxqDoc xml file from the source modulexml
xqparsexqparse xml file from the source modulexml

Imports

This module is imported by 0 modules. It imports 1 modules.

(None)
imports
this
imports

Variables

None

Functions

4.1 dba:db-query

Arities: dba:db-query#3RA

Summary
Runs a query on a document and returns the result as string.
Signature
dba:db-query ( $name as xs:string, $resource as xs:string, $query as xs:string )  as xs:string
Parameters
  • name as xs:string name of database
  • resource as xs:string resource
  • query as xs:string query
Return
  • xs:stringresult string
Invokes 2 functions from 2 modules
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:

    PrefixUri
    dbadba/databases 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
    outputhttp://www.w3.org/2010/xslt-xquery-serialization
    resthttp://exquery.org/ns/restxq
    utildba/util

    6 RestXQ

    Paths defined 1.

    PathMethodFunction
    /dba/db-queryPOSTdba:db-query#3

    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))
    };