dba/databases  library module
UR

Summary

Save users information.
Tags

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

__source : users/users-info.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

3.1 $dba:CAT

Summary
Top category
Type
xs:string

Functions

4.1 dba:users-info

Arities: dba:users-info#1UR

Summary
Saves users information.
Signature
dba:users-info ( $info as xs:string )  as empty-sequence()
Parameters
  • info as xs:string users information
Return
  • empty-sequence()redirection
Invokes 8 functions from 4 modules
  • util:redirect#2
  • {http://basex.org/modules/user}info#0
  • {http://basex.org/modules/user}update-info#1
  • {http://www.w3.org/2001/XMLSchema}QName#1
  • {http://www.w3.org/2005/xpath-functions}deep-equal#2
  • {http://www.w3.org/2005/xpath-functions}error#1
  • {http://www.w3.org/2005/xpath-functions}not#1
  • {http://www.w3.org/2005/xpath-functions}parse-xml#1
Invoked by 0 functions from 0 modules
    Annotations
    %updating()
    %rest:POST()
    %rest:path('/dba/users-info')
    %rest:form-param('info','{$info}')
    Source ( 20 lines)
    function dba:users-info(
      $info  as xs:string
    ) as empty-sequence() {
      try {
        (: change user info :)
        let $xml := if($info) then (
          parse-xml($info)/*[self::info or error(xs:QName(err:FORC0006))]
        ) else (
          <info/>
        )
        where not(deep-equal(user:info(), $xml))
        return user:update-info($xml),
    
        util:redirect($dba:CAT, map { 'info': 'User was saved.' })
      } catch err:FODC0006 {
        util:redirect($dba:CAT, map { 'error': 'Information must be XML with an info root element.' })
      } catch * {
        util:redirect($dba:CAT, map { 'error': $err:description })
      }
    }

    Namespaces

    The following namespaces are defined:

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

    6 RestXQ

    Paths defined 1.

    PathMethodFunction
    /dba/users-infoPOSTdba:users-info#1

    Source Code

    (:~
     : Save users information.
     :
     : @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';
    
    (:~ Top category :)
    declare variable $dba:CAT := 'users';
    
    (:~
     : Saves users information.
     : @param  $info  users information
     : @return redirection
     :)
    declare
      %updating
      %rest:POST
      %rest:path('/dba/users-info')
      %rest:form-param('info', '{$info}')
    function dba:users-info(
      $info  as xs:string
    ) as empty-sequence() {
      try {
        (: change user info :)
        let $xml := if($info) then (
          parse-xml($info)/*[self::info or error(xs:QName(err:FORC0006))]
        ) else (
          <info/>
        )
        where not(deep-equal(user:info(), $xml))
        return user:update-info($xml),
    
        util:redirect($dba:CAT, map { 'info': 'User was saved.' })
      } catch err:FODC0006 {
        util:redirect($dba:CAT, map { 'error': 'Information must be XML with an info root element.' })
      } catch * {
        util:redirect($dba:CAT, map { 'error': $err:description })
      }
    };