API Docs for:
Show:

BaseModel Class

Extends Base
Module: base-domain

Base model class of DDD pattern.

the parent "Base" class just simply gives a @getFacade() method.

Methods

getEntityProps

() Array public static

get list of properties which contains entity

Returns:

Array:

getFacade

() Facade

Inherited from Base: src/lib/base.coffee:32

get facade

the implementation is in Facade#requre()

Returns:

getModelProps

(
  • [options]
)
Array public static

get list of properties which contains relational model

Parameters:

  • [options] Object optional
    • [includeList] Boolean optional

      include props of BaseList

Returns:

Array:

getPropInfo

() PropInfo public

get an instance of PropInfo, which summarizes properties of this class

Returns:

include

(
  • [options]
)
Promise(BaseModel)

include all relational models if not set

Parameters:

  • [options] Object optional
    • [recursive] Boolean optional

      recursively include models or not

Returns:

Promise(BaseModel):

self

inherit

(
  • anotherModel
)
BaseModel

inherit value of anotherModel

Parameters:

Returns:

BaseModel:

this

setEntityProp

(
  • prop
  • submodel
)
BaseModel

set related model(s)

Parameters:

  • prop String

    property name of the related model

  • submodel Entity | Array

Returns:

BaseModel:

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:

Object:

plainObject

unsetEntityProp

(
  • prop
)
BaseModel

unset related model(s)

Parameters:

  • prop String

    property name of the related models

Returns:

BaseModel:

this

withParentProps

() Object protected static

extend @properties of Parent class

Returns:

Object:

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