dba/databases
library moduleURA
Summary
Create backup.
- Authors
- Christian Grün, BaseX Team 2005-23, BSD License
Imports
This module is imported by 0 modules. It imports 2 modules.
Variables
Functions
4.1 dba:backup-create
Arities: #1RA
dba:backup-create
(
$name
as
xs:string
) as
element(html)
- name
as
xs:string
database (empty string for general data)
element(html)
page
Invoked by 0 functions from 0 modules
Annotations (4)
%rest:GET | () |
%rest:path | ('/dba/backup-create') |
%rest:query-param | ('name','{$name}','') |
%output:method | ('html') |
Source ( 33 lines)
function dba:backup-create(
$name as xs:string
) as element(html) {
html:wrap(map { 'header': ($dba:CAT, $name) },
<tr>
<td>
<form action='backup-create' method='post' autocomplete='off'>
<input type='hidden' name='name' value='{ $name }'/>
<h2>{
html:link('Databases', $dba:CAT), ' » ',
(html:link($name, $dba:SUB, map { 'name': $name }), ' » ')[$name],
html:button('backup-create', 'Create Backup')
}</h2>
<table>
<tr>
<td>Comment:</td>
<td>
<input type='text' name='comment' id='comment' size='64' placeholder='optional'/>
{ html:focus('comment') }
</td>
</tr>
<tr>
<td>Compress Files:</td>
<td>{
html:checkbox('compress', 'true', true(), '')
}</td>
</tr>
</table>
</form>
</td>
</tr>
)
}
4.2 dba:db-optimize-all
Arities: #1UR
dba:db-optimize-all
(
$names
as
xs:string*
) as
empty-sequence
- names
as
xs:string*
names of databases
empty-sequence
redirection
Invoked by 0 functions from 0 modules
Annotations (4)
%updating | () |
%rest:GET | () |
%rest:path | ('/dba/backup-create-all') |
%rest:query-param | ('name','{$names}') |
Source ( 10 lines)
function dba:db-optimize-all(
$names as xs:string*
) as empty-sequence() {
try {
$names ! db:create-backup(.),
util:redirect($dba:CAT, map { 'info': util:info($names, 'database', 'backed up') })
} catch * {
util:redirect($dba:CAT, map { 'error': $err:description })
}
}
4.3 dba:db-rename
Arities: #3UR
dba:db-rename
(
$name
as
xs:string
, $comment
as
xs:string
, $compress
as
xs:string?
) as
empty-sequence
- name
as
xs:string
database (empty string for general data) - comment
as
xs:string
comment - compress
as
xs:string?
compress files
empty-sequence
redirection
Invoked by 0 functions from 0 modules
Annotations (6)
%updating | () |
%rest:POST | () |
%rest:path | ('/dba/backup-create') |
%rest:query-param | ('name','{$name}','') |
%rest:query-param | ('comment','{$comment}') |
%rest:query-param | ('compress','{$compress}') |
Source ( 12 lines)
function dba:db-rename(
$name as xs:string,
$comment as xs:string,
$compress as xs:string?
) as empty-sequence() {
try {
db:create-backup($name, map { 'comment': $comment, 'compress': boolean($compress) }),
util:redirect($dba:SUB, map { 'name': $name, 'info': 'Backup was created.' })
} catch * {
util:redirect($dba:SUB, map { 'name': $name, 'error': $err:description })
}
}
Namespaces
The following namespaces are defined:
Prefix | Uri |
---|---|
db | http://basex.org/modules/db |
dba | dba/databases 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
err | http://www.w3.org/2005/xqt-errors |
html | dba/html |
output | http://www.w3.org/2010/xslt-xquery-serialization |
rest | http://exquery.org/ns/restxq |
util | dba/util |
xs | http://www.w3.org/2001/XMLSchema |
6 RestXQ
Paths defined 3.
Path | Method | Function |
---|---|---|
/dba/backup-create | GET | dba:backup-create#1 |
/dba/backup-create | POST | dba:db-rename#3 |
/dba/backup-create-all | GET | dba:db-optimize-all#1 |
Source Code
(:~
: Create backup.
:
: @author Christian Grün, BaseX Team 2005-23, BSD License
:)
module namespace dba = 'dba/databases';
import module namespace html = 'dba/html' at '../../lib/html.xqm';
import module namespace util = 'dba/util' at '../../lib/util.xqm';
(:~ Top category :)
declare variable $dba:CAT := 'databases';
(:~ Sub category :)
declare variable $dba:SUB := 'database';
(:~
: Form for creating a backup.
: @param $name database (empty string for general data)
: @return page
:)
declare
%rest:GET
%rest:path('/dba/backup-create')
%rest:query-param('name', '{$name}', '')
%output:method('html')
function dba:backup-create(
$name as xs:string
) as element(html) {
html:wrap(map { 'header': ($dba:CAT, $name) },
<tr>
<td>
<form action='backup-create' method='post' autocomplete='off'>
<input type='hidden' name='name' value='{ $name }'/>
<h2>{
html:link('Databases', $dba:CAT), ' » ',
(html:link($name, $dba:SUB, map { 'name': $name }), ' » ')[$name],
html:button('backup-create', 'Create Backup')
}</h2>
<table>
<tr>
<td>Comment:</td>
<td>
<input type='text' name='comment' id='comment' size='64' placeholder='optional'/>
{ html:focus('comment') }
</td>
</tr>
<tr>
<td>Compress Files:</td>
<td>{
html:checkbox('compress', 'true', true(), '')
}</td>
</tr>
</table>
</form>
</td>
</tr>
)
};
(:~
: Creates a backup.
: @param $name database (empty string for general data)
: @param $comment comment
: @param $compress compress files
: @return redirection
:)
declare
%updating
%rest:POST
%rest:path('/dba/backup-create')
%rest:query-param('name', '{$name}', '')
%rest:query-param('comment', '{$comment}')
%rest:query-param('compress', '{$compress}')
function dba:db-rename(
$name as xs:string,
$comment as xs:string,
$compress as xs:string?
) as empty-sequence() {
try {
db:create-backup($name, map { 'comment': $comment, 'compress': boolean($compress) }),
util:redirect($dba:SUB, map { 'name': $name, 'info': 'Backup was created.' })
} catch * {
util:redirect($dba:SUB, map { 'name': $name, 'error': $err:description })
}
};
(:~
: Creates backups.
: @param $names names of databases
: @return redirection
:)
declare
%updating
%rest:GET
%rest:path('/dba/backup-create-all')
%rest:query-param('name', '{$names}')
function dba:db-optimize-all(
$names as xs:string*
) as empty-sequence() {
try {
$names ! db:create-backup(.),
util:redirect($dba:CAT, map { 'info': util:info($names, 'database', 'backed up') })
} catch * {
util:redirect($dba:CAT, map { 'error': $err:description })
}
};