BaseModel Class
Base model class of DDD pattern.
Methods
$include
-
[options]
include all relational models and returns new model
Parameters:
-
[options]Object optional-
[async=true]Boolean optionalget async values
-
[props]Array(String) optionalinclude only given props
-
Returns:
new model
$unset
-
prop
unset property and create a new model
Parameters:
-
propStringproperty name
Returns:
this
deprecated
-
methodName -
message
Show indication message of deprecated method
Parameters:
-
methodNameString -
messageString
Returns:
diff
-
plainObj
Get difference props
Parameters:
-
plainObjAny
Returns:
diff
-
plainObj -
[options]
Get diff props
Parameters:
-
plainObjAny -
[options]Object optional-
[ignores]Array(String) optionalprop names to skip checking diff
-
Returns:
enum
()
Object
public
Returns:
enum
()
Object(key: String => Number)
public
Returns:
error
-
reason -
[message]
create instance of DomainError
Parameters:
-
reasonStringreason of the error
-
[message]String optional
Returns:
getDiff
-
plainObj -
[options]
Get diff prop values
Parameters:
-
plainObjAny -
[options]Object optional-
[ignores]Array(String) optionalprop names to skip checking diff
-
Returns:
getParent
()
Function
get parent class
Returns:
include
-
[options]
include all relational models if not set
Parameters:
-
[options]Object optional-
[async=true]Boolean optionalget async values
-
[props]Array(String) optionalinclude only given props
-
Returns:
self
included
()
Boolean
Check if all subentities are included.
Returns:
inherit
-
anotherModel
inherit value of anotherModel
Parameters:
-
anotherModelBaseModel
Returns:
this
plainClone
()
Object
public
clone the model as a plain object
Returns:
setEnum
-
prop -
value
set enum value
Parameters:
-
propString -
valueString | Number
setRoot
()
protected
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
unset
-
prop
unset property
Parameters:
-
propStringproperty name
Returns:
this
withParentProps
()
Object
protected
static
extend @properties of Parent class
Returns:
Example:
class Parent extends BaseModel
Properties
isImmutable
Boolean
static
Flag of the model's immutablity
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 'hobby-list'
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
