Changes

Jump to navigation Jump to search
383 bytes added ,  13:52, 1 August 2022
<syntaxhighlight lang="xquery">
db:add('databasedocuments', '/path/to/xml/resources/')
</syntaxhighlight>
<syntaxhighlight lang="xquery">
let $failures errors := db:get-value('resourcesdocuments')return for $filename in map:for-eachkeys($failures, functionerrors)where ends-with($filename, $'.error') { return $filename || ': ' || $error}errors?($filename)
</syntaxhighlight>
=Export DataDatabase=
All resources stored in a database can be ''exported'', i.e., written back to disk, e.g., as follows:
* WebDAV: Locate the database directory (or a subdirectory of it) and copy all contents to another location.
=Main-Memory Database InstancesDatabases=
A database can be created in main-memory by enabling the {{Option|MAINMEM}} option. Next,in the standalone context, a main-memory database can be created, which can then be accessed by subsequent commands.
* in the standalone context, a main-memory database can be created (using {{Command|CREATE DB}}), which can then be accessed by subsequent commands.* If a BaseX server instance is started, and if a database is created in its context at startup time (, e.g., with the {{[[Command-Line Options|command-line option -c]] and a {{Command|CREATE DB}})call, other BaseX client instances clients can then access and update this database: <syntaxhighlight lang="perl"># Serverbasexserver -c"SET mainmem on" -c"CREATE DB mainmem document.xml"BaseX [Server]Server was started (port: 1984).MAINMEM: trueDatabase 'mainmem' created in 1782.80 ms. # ClientbasexclientUsername: ...Password: ...BaseX [Client]Try 'help' to get more information.> XQUERY count(db:get('mainmem')//*)1876462Query executed in 0.97 ms.</syntaxhighlight> Additional notes:
* You can force an ordinary database, or parts of it, to being temporarily copied to memory by applying an empty [[XQuery_Update#Main-Memory_Updates|main-memory update]] on a database node: <code>db:get('some-db') update { }</code>
 '''Note:''' * If you open local or remote documents with <code>fn:doc</code> or <code>fn:collection</code>, the resulting internal representation is identical to those of main-memory database instances (regardless of which value is set for {{Option|MAINMEM}}).
=Changelog=
;Version 8.4
* Updated: [[#Raw Files|Raw Files]]: Items of binary type can be output without specifying the obsolete <code>raw</code> serialization method.
;Version 7.2.1
* Updated: {{Code|fn:document-uri}} and {{Code|fn:base-uri}} now return strings that can be reused with {{Code|fn:doc}} or {{Code|fn:collection}} to reopen the original document.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu