new Storage()
Constructor: Initializes the database and all return values.
Requires
- module:easejs
- module:AttributeValue
- module:AttributeValueList
- module:Parameter
- module:ParameterList
- module:RetrievalResult
Members
-
privateattributeNamesArray
-
Names of all stored Attributes (tableNames as string).
-
privateattributesRetrievalResult
-
Data of a retrieval.
-
privatecountConditionNumber
-
Condition at which point of time data are supposed to be flushed. If at least 'countCondition' attributes are collected data will be flushed. Initial value is 5.
-
privatedataAttributeValueList
-
Cache before storing the new data in the database.
-
privatedataCountInteger
-
Names of all stored Attributes.
-
privatedbDatabase
-
Associated database.
-
privatelastFlushDate
-
Time of the last flush.
-
privatetimeConditionInteger
-
Condition (ms) at which point of time data are supposed to be flushed. If the value is more than the value of 'timeCondition' ago, data should be flushed again. The initial value is two hours.
Methods
-
privateaddData(_attributeValue)
-
Adds data to the local cache. The cache is used to decrease the database access.
Name Type Description _attributeValue
AttributeValue Value that should be stored. -
privatecheckFlushCondition(){boolean}
-
Verifies the flush conditions.
-
privatecreateTable(_attribute, _function)
-
Creates a new table. A table contains the values of one AttributeType. So the name is the AttributeName.
Name Type Description _attribute
String tableName (should be the attributeName) _function
function nullable For alternative actions, if an asynchronous function is used. -
privateflushStorage()
-
Stores all data from the local cache to the database.
-
getAttributeNames(_function)
-
Sets the attributeNames array.
Name Type Description _function
function nullable For alternative actions, if an asynchronous function is used. -
getAttributesOverview(){Array}
-
Returns the names of all stored Attributes (tableNames as string).
-
getCountCondition()
-
Returns the current count condition for flush.
-
getCurrentData(){RetrievalResult}
-
Returns the last retrieved Attributes.
-
getTimeCondition(){integer}
-
Returns the current time condition for flush.
-
privateinitStorage(_name)
-
Initializes a new database.
Name Type Description _name
String Name of the database. -
privateinsertIntoTable(_attributeValue, _function)
-
Inserts value into a table. The name of the given Attribute identifies the table.
Name Type Description _attributeValue
AttributeValue Attribute that should be stored. _function
function nullable For alternative actions, if an asynchronous function is used. -
privateresetForFlush()
-
Clears the local cache.
-
privateresolveAttributeName(_tableName)
-
Extracts the attributeName form the table name.
Name Type Description _tableName
String Table name that should be resolved. -
privateresolveParameters(_tableName)
-
Extracts the parameters form the table name.
Name Type Description _tableName
String Table name that should be resolved. -
retrieveAttributes(_tableName, _function)
-
Retrieves a table and sets the RetrievalResult.
Name Type Description _tableName
String Name for the table that should be retrieved. _function
function nullable For additional actions, if an asynchronous function is used. -
setCountCondition(_counter)
-
Sets the counter for flush.
Name Type Description _counter
integer counter -
setTimeCondition(_time)
-
Sets the time condition for flush.
Name Type Description _time
integer time in ms -
store(_attributeValue)
-
Stores the given Attribute. If the flush condition does not match, the data is first added to the local cache before.
Name Type Description _attributeValue
AttributeValue Value that should be stored. -
privatetableExists(_attribute){boolean}
-
Verifies if a table for an attribute exists.
Name Type Description _attribute
AttributeValue | String Attribute or name for the verification. -
privatetableName(_attribute)
-
Builds the tableName for the given attribute.
Name Type Description _attribute
AttributeValue Attribute that should be stored.
Type Definitions
-
errorCB
-
error function
-
queryTables
-
Sets the attributeNames array. Is used in getAttributeNames().
-
queryTableSucces
-
Success function for queryTable.
-
queryValues
-
Query function for given attribute.
-
queryValuesSucces
-
Success function for retrieveAttributes(). Puts the retrieved data in RetrievalResult object.
-
successCB
-
success function