The DefaultModel class holds all the methods which relate to the database

Extends AbstractModel

Methods

_buildQueryColumns (query)

private

In this method the specific functions to select the columns can be added.

Parameters

Name Type Description
query SelectQuery The select query from RaddishDB.

Returned Value

Promise: A promise containing the query object.


_buildQueryFrom (query)

private

This method is used to specify from which table the data needs to come.

Parameters

Name Type Description
query SelectQuery The select query from RaddishDB.

Returned Value

Promise: A promise containing the query object.


_buildQueryGroup (query)

private

The _buildQueryGroup method will hold all the functions to specify the group clauses. By default no group is added.

Parameters

Name Type Description
query SelectQuery The select query from RaddishDB.

Returned Value

Promise: A promise containing the query object.


_buildQueryHaving (query)

private

The _buildQueryGroup method will hold all the functions to specify the having clauses. By default no having is added.

Parameters

Name Type Description
query SelectQuery The select query from RaddishDB.

Returned Value

Promise: A promise containing the query object.


_buildQueryJoins (query)

private

This method will hold the specific calls for the Join methods.

Parameters

Name Type Description
query SelectQuery The select query from RaddishDB.

Returned Value

Promise: A promise containing the query object.


_buildQueryLimit (query)

private

The _buildQueryLimit method will hold all the functions to specific for the limit and offset. When the limit and offset states have been set the values will be added to the query.

Parameters

Name Type Description
query SelectQuery The select query from RaddishDB.

Returned Value

Promise: A promise containing the query object.


_buildQueryOrder (query)

private

The _buildQueryOrder method will hold all the functions to specify the ordering done on the data. When the order and direction states have been set the values will be added to the query.

Parameters

Name Type Description
query SelectQuery The select query from RaddishDB.

Returned Value

Promise: A promise containing the query object.


_buildQueryWhere (query)

private

This method will hold all the functionality to add the Where clause to the query. By default filled unique states are added to the query.

Parameters

Name Type Description
query SelectQuery The select query from RaddishDB.

Returned Value

Promise: A promise containing the query object.


_getComponentConfig (identifier, config)

private

The _getComponentConfig is an internal method to combine all the config object together. Usually you don't have to call this method manually.

Parameters

Name Type Description
identifier Identifier The identifier object of the object to load.
config Object The config object for the object to load.

Returned Value

Object: The complete and combined config object.


_initialize (config)

private

The abstract initialize method sets the config, and when behaviors are added it will allocate them.

Parameters

Name Type Description
config Object the config for this object

Returned Value

Promise: A promise containing the initialized object.


clone ()

The clone method will return a clone of the current object. The clone is going exactly 4 levels deep.

Returned Value

Object: The cloned object.


execute (method, context)

The execute method executes a method against the command chain.

Parameters

Name Type Description
method Object The method to execute
context Object A simple object to act as the basic context.

Returned Value

Promise: A promise containing the context with the result of the call.


getCommandChain ()

The getCommandChain will return the command chain for the current object.

Returned Value

CommandChain: The command chain object.


getIdentifier ()

The getIdentifier method will return the identifier for the current object.

Returned Value

Identifier: The identifier object from Raddish-Loader


getItem ()

Inherited from AbstractModel but overwritten in lib/model/default.js:21

The getItem method of the DefaultModel will build a query for the database.

The methods called to build the query are:

  • _buildQueryFrom
  • _buildQueryColumns
  • _buildQueryJoins
  • _buildQueryWhere
  • _buildQueryGroup
  • _buildQueryHaving

Returned Value

Promise: A promise containing a row object with data from the database.


getList ()

Inherited from AbstractModel but overwritten in lib/model/default.js:68

The getList method will build a query for the database. This method will always return a Rowset object with data from the database.

The methods called to build the query are:

  • _buildQueryFrom
  • _buildQueryColumns
  • _buildQueryJoins
  • _buildQueryWhere
  • _buildQueryGroup
  • _buildQueryHaving
  • _buildQueryOrder
  • _buildQueryLimit

Returned Value

Promise: A promise containing a Rowset object with data from the database.


getObject (identifier, config)

The getObject method will try to load the specified identifier. An optional config can be given for the identifier to load.

Parameters

Name Type Description
identifier String|Identifier An identifier string/ object.
config Object An optional config object.

Returned Value

Promise: A promise containing the initialized object.


getTable ()

This method will return the table related to the model.

Returned Value

Promise: A promise containing the table object.


setState (key, value)

This method will set the states of the model.

Parameters

Name Type Description
key String| Object The state name/ object of states to set.
value * The value for the state.

Returned Value

AbstractModel: The current model object for chaining.