NohmStaticModel

NohmStaticModel

new NohmStaticModel()

Source:

The static Model Class, used to get instances or operate on multiple records.

Members

(static) this.client :RedisClient

Source:

Redis client that is set for this Model. Defaults to the NohmClass client it was registered in.

Type:
  • RedisClient

(static) this.modelName :string

Source:

Name of the model, used for database keys and relation values

Type:
  • string

Methods

(async, static) find(searchesopt) → {Promise.<Array.<string>>}

Source:
See:
  • NohmModel.find

Search for ids

Parameters:
Name Type Attributes Default Description
searches ISearchOptions <optional>
{}

Search options

Returns:

Array of ids

Type
Promise.<Array.<string>>

(async, static) .findAndLoad(searches) → {Promise.<Array.<NohmModel>>}

Source:

Finds ids of objects and loads them into full NohmModels.

Parameters:
Name Type Description
searches ISearchOptions
Returns:
Type
Promise.<Array.<NohmModel>>

(async, static) .load(id) → {Promise.<NohmModel>}

Source:

Creates a new model instance and loads it with the given id.

Parameters:
Name Type Description
id *

ID of the model to be loaded

Throws:

If no record exists of the given id, an error is thrown with the message 'not found'

Type
Error('not found')
Returns:
Type
Promise.<NohmModel>

(async, static) .loadMany(ids) → {Promise.<NohmModel>}

Source:

Loads an Array of NohmModels via the given ids. Any ids that do not exist will just be ignored. If any of the ids do not exist in the database, they are left out instead of throwing an error. Thus if no ids exist an empty error is returned.

Parameters:
Name Type Description
ids Array.<string>

Array of IDs of the models to be loaded

Returns:
Type
Promise.<NohmModel>

(async, static) remove(id) → {Promise.<NohmModel>}

Source:

Loads a NohmModels via the given id.

Parameters:
Name Type Description
id *

ID of the model to be loaded

Returns:
Type
Promise.<NohmModel>

(async, static) .sort(sortOptionsopt) → {Promise.<Array.<string>>}

Source:
See:
  • NohmModel.sort

Sort the given ids or all stored ids by their SortOptions

Parameters:
Name Type Attributes Default Description
sortOptions ISortOptions.<IDictionary> <optional>
{}

Search options

Returns:

Array of ids

Type
Promise.<Array.<string>>