API - Model

Extends AbstractModel

Default model used in most cases.

Methods

buildQueryColumns will determine which columns need to be fetched from the table. by default this is "tbl.*"

Parameters
Name Type Description
query Object The querybuilder object

Returns Object: The querybuilder object.

The buildQuiryFrom method will determin from which table the data needs to be fetched. This table will get the alias "tbl" by default.

Parameters
Name Type Description
query Object The querybuilder object

Returns Object: The querybuilder object.

The buildQueryGroup will group the row together. By default no group query is made.

Parameters
Name Type Description
query Object The querybuilder object

Returns Object: The querybuilder object.

The buildQueryHaving will add a having statement to the query. By default no having statements will be added.

Parameters
Name Type Description
query Object The querybuilder object

Returns Object: The querybuilder object.

The buildQueryJoins will define which joins need to be made. By default no joins are made.

Parameters
Name Type Description
query Object The querybuilder object

Returns Object: The querybuilder object.

BuildQueryLimit will use the limit and offset states to return the records When both aren't specified the default of limit is "20" and the default of offset is "0".

Parameters
Name Type Description
query Object The querybuilder object

Returns Object: The querybuilder object.

The buildQueryOrder will determine the order and direction on which to sort. By default the state sort and direction are used. When the state sort has a value this value is used, and by default the order is ascending, unless the direction state has been modified.

Parameters
Name Type Description
query Object The querybuilder object

Returns Object: The querybuilder object.

The buildQueryWhere will create the where statements on the query. By default unique states are filtered, this only happens when they have a value.

Parameters
Name Type Description
query Object The querybuilder object

Returns Object: The querybuilder object.

This function will be available for every object, this will clone the current object.

Returns Object: An exact copy of the current object

This is a private function to allow for config extending This method takes two parameters the first is the original config and the second will be appeneded to this one.

Parameters
Name Type Description
target Object The config object.
source Object The object to extend the config object.

Return the command chain to run behaviors.

Returns CommandChain: CommandChain object.

Use this function to acquire a variable from config.js

Parameters
Name Type Description
key String Key to specify the config to return

Returns Object: The requested config value.

Use this function to acquire the identifier object

Returns ObjectIdentifier: Identifier object.

getItem override of AbstractModel, this will create a complete query and execute this query on the table.

Returns Promise: The promise with a single item from the table as content.

This method will retreive a complete list of objects from the table, this will also create a query using the buildQuery methods.

Returns Promise: A promise with the list of object as content

This is a alias of ObjectManager.getObject to use in the "this" context.

Parameters
Name Type Description
identifier String Identifier of the object to load
config Object|null Config to push to the object

Returns Promise: call ".then" to use the object when ready.

This method will return the table connected to the current model.

Returns Promise: The promise holding the table object as content.

A special query is being build to get the total of objects from the table.

Returns Promise: A promise holding the total number of objects as content.

Every object called through getObject will go through this function. This will set the identifier and adds the behaviors (if any).

Parameters
Name Type Description
config Object Object with config values

Returns Promise: call ".then" to use the object when ready.

This is the handler which will try to mixin functions from another object.

Parameters
Name Type Description
object Object The object to mix into the current object.

This method is used to set the states. This method accepts an array or a string as the first parameter. When the first parameter is a string the second parameter will be the value of this state.

Parameters
Name Type Description
name Object|string The state/ array of states to set
value * The value of the state

Returns AbstractModel: The current model with set states.