Current revision of the database. Incremented at every change in a table.
Persistent storage of the database. It is automatically saved and loaded by the database, but is publicly exposed and provide no special feature like revisions.
Tables of the database. The keys are the table names, and the values are the related DatabaseTable objects.
Local storage key used to save the serialized database content.
Clear any local storage field holding database data.
Note: if the local storage is not available, nothing happen.
Empty the database content (set to default values), and clear all data saved in the local storage.
Get the current revision of the database.
The current revision of the database.
Get all item click logs stored in the database.
A readonly array of all item click logs (as table entries).
Get the index where the next item click log would be inserted in the table.
Note: this is also equal to the number of item click log entries.
The index of the next item click log entry.
Get all page visit logs stored in the database.
A readonly array of all page visit logs (as table entries).
Get the index where the next page visit log would be inserted in the table.
Note: this is also equal to the number of page visit log entries.
The index of the next page visit log entry.
Initializes the database and its content.
Even a partial save can be loaded: the related fields are updated with the loaded content (see loadFromLocalStorage), while the others are set to default values (see setContentToDefault).
Test whether some database data is available in the local storage.
true
if the local storage is available and the value for key
Database.LOCAL_STORAGE_KEY is not null
, false
otherwise.
Test whether the given revision is equal to the current one.
The revision to compare to the current one.
true
if the two revisions are equal, false
otherwise.
Load a JSON description database data from the local storage, unserialize it, and update internal fields with available data (see unpackDataFromJSON).
Note: if the local storage is not available, nothing happen.
Save the given item click log in the dedicated database table.
The item click log to save.
The new revision of the database.
Save the given page visit log in the dedicated database table.
The page visit log to save.
The new revision of the database.
Page unload callback: save the database content in the local storage.
Group all the data to save, and serialize it as a single JSON string.
Note: the data must be natively compatible with JSON serialization,
using JSON.stringify
(e.g. it does not work with Map
s).
A JSON string representing the serialized data.
Group and serialize the database data into a JSON description (see packDataToJSON), and save it in the local storage.
Note: if the local storage is not available, nothing happen.
Set or reset the database content to default values (empty content).
Note: this does not affect any data stored in the local storage.
Start listening for page unload events.
Unserialize the given JSON string, which must represent grouped data (according to packDataToJSON protocol), and update all internal fields for which some data is available (i.e. non-undefined values). *
A JSON string representing the serialized data.
Generated using TypeDoc
Create a new instance of Database.