BaseModel Class
Base model class of DDD pattern.
the parent "Base" class just simply gives a @getFacade() method.
Item Index
Methods
- getEntityProps static
- getFacade
- getModelProps static
- getPropInfo
- include
- inherit
- setEntityProp
- toPlainObject
- unsetEntityProp
- withParentProps static
Properties
- properties static
- TYPES static
Methods
getEntityProps
()
Array
public
static
get list of properties which contains entity
Returns:
getModelProps
-
[options]
get list of properties which contains relational model
Parameters:
-
[options]Object optional-
[includeList]Boolean optionalinclude props of BaseList
-
Returns:
getPropInfo
()
PropInfo
public
get an instance of PropInfo, which summarizes properties of this class
Returns:
include
-
[options]
include all relational models if not set
Parameters:
-
[options]Object optional-
[recursive]Boolean optionalrecursively include models or not
-
Returns:
self
inherit
-
anotherModel
inherit value of anotherModel
Parameters:
-
anotherModelBaseModel
Returns:
this
setEntityProp
-
prop -
submodel
set related model(s)
Parameters:
-
propStringproperty name of the related model
-
submodelEntity | Array
Returns:
this
toPlainObject
()
Object
create plain object without relational entities descendants of Entity are removed, but not descendants of BaseModel descendants of Entity in descendants of BaseModel are removed ( = recursive)
Returns:
plainObject
unsetEntityProp
-
prop
unset related model(s)
Parameters:
-
propStringproperty name of the related models
Returns:
this
withParentProps
()
Object
protected
static
extend @properties of Parent class
Returns:
Example:
class Parent extends BaseModel
Properties
properties
Object
protected
static
key-value pair representing property's name - type of the model
firstName : @TYPES.STRING
lastName : @TYPES.STRING
age : @TYPES.NUMBER
registeredAt : @TYPES.DATE
team : @TYPES.MODEL 'team'
hobbies : @TYPES.MODEL_LIST 'hobby'
info : @TYPES.ANY
see type-info.coffee for full options.
TYPES
Object
protected
final
static
key-value pair representing typeName - type
use for definition of @properties for each extender
