Changes

Jump to navigation Jump to search
14 bytes added ,  16:04, 19 July 2022
no edit summary
|}
==db:get-binary==
{{Announce|Introduced Updated with Version 10.}}: renamed (before: {{Code|db:retrieve}}).
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|db:get-binary|$db as xs:string, $path as xs:string|item()*xs:base64Binary}}
|-
| '''Summary'''
|Returns an XQuery value stored in a [[Binary Data|binary resource]] addressed by the database {{Code|$db}} at the specified and {{Code|$path}} as [[Streaming Module|streamable]] {{Code|xs:base64Binary}}.
|-
| '''Errors'''
| '''Examples'''
|
* {{Code|db:get-binary('"DB'", 'sequence'"music/01.mp3")}} returns the specified sequenceaudio file as raw data.* <code><nowiki>stream:materialize(db:get-binary("DB", "music/01.mp3"))</nowiki></code> materializes the streamable result in main-memory before returning it.* <code><nowiki>convert:binary-to-string(db:get-binary("DB", "info.txt"), 'UTF-8')</nowiki></code> converts a binary database resource as UTF-8 text and returns a string.
|}
==db:get-binaryvalue==
{{Announce|Updated Introduced with Version 10.}}: renamed (before: {{Code|db:retrieve}}).
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|db:get-binaryvalue|$db as xs:string, $path as xs:string|xs:base64Binaryitem()*}}
|-
| '''Summary'''
|Returns a [[Binary Data|binary resource]] addressed by an XQuery value stored in the database {{Code|$db}} and at the specified {{Code|$path}} as [[Streaming Module|streamable]] {{Code|xs:base64Binary}}.
|-
| '''Errors'''
| '''Examples'''
|
* {{Code|db:get-binaryvalue("'DB"', "music/01.mp3"'sequence')}} returns the specified audio file as raw data.* <code><nowiki>stream:materialize(db:get-binary("DB", "music/01.mp3"))</nowiki></code> materializes the streamable result in main-memory before returning it.* <code><nowiki>convert:binary-to-string(db:get-binary("DB", "info.txt"), 'UTF-8')</nowiki></code> converts a binary database resource as UTF-8 text and returns a stringsequence.
|}
| '''Summary'''
|Adds documents specified by {{Code|$input}} to the database {{Code|$db}} with the specified {{Code|$path}}:
* A document with the same path may occur more than once in a database. If you want to enforce single instances, use {{Function||db:updateput}} instead.
* See {{Function||db:create}} for more details on the input and path arguments.
* The parsing behavior can be controlled via {{Code|$options}}:
|}
==db:updateput==
{{Announce|Updated with Version 10}}: renamed (before: {{Code|db:replace}}); function signature aligned with {{Function||db:add}} (second and third argument swapped).
|-
| width='120' | '''Signatures'''
|{{Func|db:updateput|$db as xs:string, $input as item(), $path as xs:string|empty-sequence()}}<br/>{{Func|db:updateput|$db as xs:string, $input as item(), $path as xs:string, $options as map(*)?|empty-sequence()|empty-sequence()}}
|-
| '''Summary'''
| '''Examples'''
|
* {{Code|db:updateput("DB", "/home/dir/doc.xml", "docs/dir/doc.xml")}} replaces the content of the document {{Code|docs/dir/doc.xml}} in the database {{Code|DB}} with the content of the file {{Code|/home/dir/doc.xml}}.* {{Code|db:updateput("DB", "<a/>", "docs/dir/doc.xml")}} replaces the content of the document {{Code|docs/dir/doc.xml}} in the database {{Code|DB}} with {{Code|&lt;a/&gt;}}.* {{Code|db:updateput("DB", document { <a/> }, "docs/dir/doc.xml")}} replaces the content of the document {{Code|docs/dir/doc.xml}} in the database {{Code|DB}} with the specified document node.
The following query can be used to import files from a directory to a database:
<syntaxhighlight lang="xquery">
let $path := $source || $file
where not(file:is-dir($path))
return db:updateput('db', doc($path), $file)
</syntaxhighlight>
|}
==db:put-value==
{{Announce|Introduced with Version 10.}}
|-
| width='120' | '''Signatures'''
|{{Func|db:put-value|$db as xs:string, $input as item()*, $path as xs:string|empty-sequence()}}
|-
| '''Summary'''
| '''Examples'''
|
* {{Code|db:put-value('DB', 1 to 10000, 'sequence')}} stores a numeric range in the database.
* With the following query, a map with countries and associated cities is stored in a database. The value resource can e.g. be used as index in future queries:
<syntaxhighlight lang="xquery">
db:put-value(
'factbook',
map:merge(
* Added: {{Function||db:get}}, {{Function||db:put}}, {{Function||db:type}}.
* Added: [[#Backups|Backups]]: Support for general data ([[User Management|registered users]], [[Jobs Module#Services|scheduled services]] and [[Store Module|key-value stores]]).
* Updated: {{Function||db:replaceput}} and {{Function||db:put-binary}} renamed (before: {{Code|db:replace}} and {{Code|db:store}}); function signature aligned with {{Function||db:add}} (second and third argument swapped).
* Updated: {{Function||db:get-binary}} renamed (before: {{Code|db:retrieve}}).
* Updated: {{Function||db:backups}}, {{Function||db:create-backup}}: Options added.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu