Module: abstractDefinitions

abstractDefinitions

Library of common methods for manipulating definitions (tiles and extstreams).

Source:

Methods

<static> addEventHandler(definitionName, eventName, handler, description) → {Promise}

Adds a listener to the named definition, for the named event.

Parameters:
Name Type Description
definitionName String
eventName String
handler function
description String
Source:
Returns:

Promise

Type
Promise

<static> find(criteria, expectOne) → {Promise}

Find definitions in persistence using the provided key-value criteria map. For example:

 {
     'name': 'samplelist'
 }

On success, the returned promise will be resolved with an array of the located objects (which may be empty if none is found matching the criteria). If failure, the promise will be rejected with an error.

Parameters:
Name Type Description
criteria Object
expectOne Boolean

If true, the promise will be resolved with at most 1 found item, or null (if none are found).

Source:
Returns:

Promise

Type
Promise

<static> findAll() → {Promise}

Searches persistence for definitions. The collection that is searched is defined in subclasses of this class (@see abstractDefinitions:getCollection). The promise will resolve with an empty array, or populated array, depending on whether any definitions exist.

Source:
Returns:

Promise

Type
Promise

<static> findByID(definitionID) → {Promise}

Searches persistence for a definition that matches the given ID (the 'id' attribute). The collection that is searched is defined in subclasses of this class (@see abstractDefinitions:getCollection). If one is not found, the promise will resolve a null (undefined) value.

Parameters:
Name Type Description
definitionID String

Id of the definition to be retrieved.

Source:
Returns:

Promise

Type
Promise

<static> findByTileName(definitionName) → {Promise}

Searches persistence for a definition that matches the given name (the 'name' attribute). The collection that is searched is defined in subclasses of this class (@see abstractDefinitions:getCollection). If one is not found, the promise will resolve a null (undefined) value.

Parameters:
Name Type Description
definitionName String

Name of the definition to be retrieved.

Source:
Returns:

Promise

Type
Promise

<static> remove(definitionID) → {Promise}

Removes a definition from persistence with the specified id (attribute 'id'). The collection that is searched is defined in subclasses of this class (@see abstractDefinitions:getCollection).

Parameters:
Name Type Description
definitionID String
Source:
Returns:

Promise

Type
Promise

<static> save(definition) → {Promise}

Save a definition to persistence. If the object does not have an id attribute, a random String is assigned. If the object is already present in persistence, it will be updated; otherwise it will be inserted. On success, the returned promise will be resolved with the inserted or updated object; if failure, the promise will be rejected with an error.

Parameters:
Name Type Description
definition Object
Source:
Returns:

Promise

Type
Promise