Database

Services. Database

A class representing a local database.

Constructor

new Database()

Source:

Members

idb :IndexedDB

A reference to the IndexedDB instance. This needs to be a publicly-accessible property for testing purposes.

Source:
Type:
  • IndexedDB

languages :DatabaseCollection

The Languages collection.

Source:
Type:
  • DatabaseCollection

lexemes :DatabaseCollection

The Lexemes collection.

Source:
Type:
  • DatabaseCollection

(constant) name

Default Value:
  • "Lotus"
Source:

texts :DatabaseCollection

The Texts collection.

Source:
Type:
  • DatabaseCollection

types :Object

A lookup of database types, with their corresponding object store names.

Source:
Type:
  • Object

(constant) version

Source:

Methods

addAnalysisLanguage(languageCID, analysisLanguage) → {Promise.<Language>}

Add a new analysis language to the specified Language, and update all of the database items related to the specified language. All properties on the analysis language are required, even if they are empty strings.

Source:
Parameters:
Name Type Description
languageCID String

The CID of the language to add the new analysis language to.

analysisLanguage Object

The analysis language to add to the language.

Name Type Description
abbreviation String

The abbreviation for this analysis language.

language String

The name of this analysis language.

tag String

The IETF language tag for this analysis language.

Returns:
Type:
Promise.<Language>

Returns a promise that resolves to the updated Language.

deleteAnalysisLanguage(languageCID, tag) → {Promise.<Language>}

Source:
Parameters:
Name Type Description
languageCID String

The CID of the language to delete.

tag String

The IETF language tag to delete from the language.

Returns:
Type:
Promise.<Language>

Returns a Promise that resolves to the updated Language.

deleteDatabase() → {Promise}

Delete the database.

Source:
Returns:
Type:
Promise

exportData() → {Promise.<Array>}

Export all the data in the database and return an Array of JavaScript Objects.

Source:
Fires:
  • Database#event:onupdate
Returns:
Type:
Promise.<Array>

importData(dataopt) → {Promise.<(Object|Array)>}

Import one or more items into the database.

Source:
Parameters:
Name Type Attributes Default Description
data Object | Array <optional>
[]

An Object, an Array of Objects, or an Array of Arrays of Objects, to import.

Returns:
Type:
Promise.<(Object|Array)>

Returns the added item or Array of items.

(async) initialize() → {Promise}

Initialize the database.

Source:
Returns:
Type:
Promise

Events

onupdate

onupdate event. This event is fired during long-running database processes each time an item is added/retrieved/modified/deleted.

Properties:
Name Type Description
count Integer

The current total number of items that have been updated so far.

total Integer

The total number of items to update.

Source:
Type:
  • Object