Changes

Jump to navigation Jump to search
1,497 bytes added ,  15:27, 10 January 2019
no edit summary
=Conventions=
 
{{Mark|Updated with Version 9.0:}}
All functions and errors in this module are assigned to the <code><nowiki>http://basex.org/modules/db</nowiki></code> namespace, which is statically bound to the {{Code|db}} prefix.<br/>
==Database Nodes==
Database nodes are XML nodes which are either stored in a persistent database, or which contained in are a sonode of a main-called ''memory database fragment''representation. All XML fragments can be converted to a main-memory database fragments by e. g. applying the [[XQuery_Update#update|update]] or [[XQuery_Update#transform|transform]] expression on an XML fragmenta node:
<pre class="brush:xquery">
copy $c db:= node-id(element hello { 'world' } modify (update {}) return $c
</pre>
==db:option==
 
{{Mark|Introduced with Version 9.0:}}
{| width='100%'
| '''Summary'''
|Returns the current value (string, integer, boolean, map) of a global or local [[Options|Option]] with the specified {{Code|$name}}. The {{Command|GET}} command works similar.
|-
| '''Errors'''
|{{Error|option|#Errors}} the specified option is unknown.
|-
| '''Examples'''
|
* {{Code|db:list-details("shop")}} returns the names plus additional info on all resources of a database named {{Code|shop}}.
|}
 
==db:dir==
 
{{Mark|Introduced with Version 9.2:}}
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|db:dir|$db as xs:string, $path as xs:string|element()*}}
|-
| '''Summary'''
|Returns meta data on all directories and resources of the database {{Code|$db}} in the specified directory {{Code|$path}}. Two types of elements are returned:
* {{Code|resource}} represents a resource. The element value is the directory path; content type, modification date, raw flag (which indicates if the resource is binary or XML), and size of the resource are returned as attributes.
* {{Code|dir}} represents a directory. The element value is the directory path; the modification date is returned as attribute.
Please note that directories are not stored in BaseX. Instead, they result implicitly from the paths of stored resources.
|-
| '''Errors'''
|{{Error|open|#Errors}} the addressed database does not exist or could not be opened.<br/>{{Error|path|#Errors}} the specified path is invalid.
|-
| '''Examples'''
|
* {{Code|db:dir('shop', 'books')}} returns all entries of the {{Code|books}} directory of a {{Code|shop}} database.
|}
==db:text==
 
{{Mark|Updated with Version 9.1}}: Support for multiple string values.
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|db:text|$db as xs:string, $strings as xs:string as item()*|text()*}}
|-
| '''Summary'''
|Returns all text nodes of the database {{Code|$db}} that have one of the specified {{Code|$stringstrings}} as their string value values and that are stored in the text index.
|-
| '''Errors'''
==db:attribute==
 
{{Mark|Updated with Version 9.1}}: Support for multiple string values.
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|db:attribute|$db as xs:string, $strings as xs:string as item()*|attribute()*}}<br/>{{Func|db:attribute|$db as xs:string, $string strings as item()xs:strings*, $name as xs:string|attribute()*}}
|-
| '''Summary'''
|Returns all attribute nodes of the database {{Code|$db}} that have one of the specified {{Code|$stringstrings}} as string value values and that are stored in the attribute index.<br />If {{Code|$name}} is specified, the resulting attribute nodes are filtered by their attribute name.
|-
| '''Errors'''
==db:token==
 
{{Mark|Updated with Version 9.1}}: Support for multiple string values.
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|db:token|$db as xs:string, $token tokens as item()xs:string*|attribute()*}}<br/>{{Func|db:token|$db as xs:string, $token tokens as item()xs:string*, $name as xs:string|attribute()*}}
|-
| '''Summary'''
|Returns all attribute nodes of the database {{Code|$db}}, the value values of which contains contain one of the specified {{Code|$tokentokens}}.<br />If {{Code|$name}} is specified, the resulting attribute nodes are filtered by their attribute name.
|-
| '''Errors'''
=Errors=
 
{{Mark|Updated with Version 9.0:}}
{| class="wikitable" width="100%"
|{{Code|open}}
|The addressed database does not exist or could not be opened.
|-
|{{Code|option}}
|The specified option is unknown.
|-
|{{Code|path}}
|-
|{{Code|property}}
|A The specified database property is unknown.
|-
|{{Code|range}}
=Changelog=
 
;Version 9.2
 
* Added: [[#db:dir|db:dir]]
;Version 9.0
* Added: [[#db:option|db:option]]
* Updated: db:output renamed to {{Function|Update|update:output}}, db:output-cache renamed to {{Function|Update|update:output-cache}}
* Updated: error codes updated; errors now use the module namespace
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu