Database View
Central to this view is a list in which the tables (aka object stores) belonging to a database are displayed. If it is an empty database that does not contain any tables, there is a link that can be used to invoke Create Table.
In the database view, the icon in the window title bar opens the database tools, while the icon opens the configuration options that apply to this database and serve as default settings for the tables it contains.
Clicking on the database part of the breadcrumb navigation reloads the database list or returns to it if a datatable is displayed in the current view.
Table List
For each table, its name, its primary key and further indexes, and the number of records it contains are displayed.
If you hover one of the rows, another icon will appear next to the row, which can be used to open the table tools. To switch to the view of one of the data tables, click on the corresponding row in the table.
Database Tools
To invoke the database tools use either the gear icon in the window title bar of the database view or the same icon next to a database row in the origin view. You can choose to import data or export the database, create an additional table, modify the database schema or to delete the database.
Export Database
The database export uses the dexie format for the output file, a json-based format that supports all data types (beside CryptoKey) that can be stored in IndexedDB databases.
Hovering the icon displays the export options that will be applied. To adjust the export options, click the icon on the right. The export options are documented in Configuration / Export.
Import Data
Under import data in the Database Tools, a file in dexie format can be selected. This file can contain the export of an entire database, the export of a single table, or the export of selected data records from a table, depending on whether it was created in the Database Tools, the Table Tools, or the Selection Tools.
Hovering the icon displays the import options that will be applied. To adjust the import options, click the icon. The import options are documented in Configuration / Import.
Create Table
If create table is selected, you can enter the name for a new table and a string representation of the indexes to be created for the table. Any string is allowed as the table name, with the only restriction that it must be unique within the database.
Within the indexes string, the individual indexes are separated by commas. Since the keypaths parts of an index refer to object properties, a valid keypath consists of valid JavaScript identifiers, possibly separated by dots. The complete syntax for index strings is described in the dexie documentation.
As with all actions that change the database schema, the database version is increased.
Modify Database Schema
When edit database schema is selected from the Database Tools, a textarea containing the database schema as a JavaScript object is displayed below the table with the databases.
Adding additional rows to the JavaScript object will create new tables in the database. Changing an existing table name will also result in the creation of a new table with the new name. To delete a table, replace the index specification with null
. The index specification can be customized as desired, with the exception that changing the primary key, the first part of the specification, is not allowed. A table whose row is completely removed remains unchanged, the same result as for a row that is not changed at all.
If const newSchema
from the example above is changed as follows and the execute button is clicked, the air quality
table is deleted, in the meteorites
table the year
index is deleted and a category
index is added , and a new sattelites
table is created with an auto increment primary key.
const newSchema = {
"air quality": null,
meteorites: "id,&name,category",
sattelites: "++"
};
When editing newSchema
, make sure that a valid JavaScript object is preserved, otherwise an error message will be displayed when executing. After successful execution, the database version is increased by 1.
Delete Database
After confirmation, the selected database will be permanently deleted. To avoid damage, it is always a good idea to create a backup beforehand using export database.