API Docs for:
Show:

Entity Class

Base model class with "id" column

Methods

$include

(
  • [options]
)
Promise(BaseModel)

include all relational models and returns new model

Parameters:

  • [options] Object optional
    • [async=true] Boolean optional

      get async values

    • [props] Array(String) optional

      include only given props

Returns:

Promise(BaseModel):

new model

$set

() BaseModel

set value to prop and create a new model

Returns:

BaseModel:

this

$unset

(
  • prop
)
BaseModel

unset property and create a new model

Parameters:

  • prop String

    property name

Returns:

BaseModel:

this

clone

() BaseModel public

create clone

Returns:

copyWith

() BaseModel

shallow copy the model with props

Returns:

deprecated

(
  • methodName
  • message
)
Error protected

Show indication message of deprecated method

Parameters:

  • methodName String
  • message String

Returns:

Error:

diff

(
  • plainObj
  • [options]
)
Array(String) public

Get diff props

Parameters:

  • plainObj Any
  • [options] Object optional
    • [ignores] Array(String) optional

      prop names to skip checking diff

Returns:

Array(String):

enum

() Object(key: String => Number) public

Returns:

Object(key: String => Number):

equals

(
  • entity
)
Boolean

check equality

Parameters:

Returns:

Boolean:

error

(
  • reason
  • [message]
)
Error

create instance of DomainError

Parameters:

  • reason String

    reason of the error

  • [message] String optional

Returns:

Error:

getDiff

(
  • plainObj
  • [options]
)
Object public

Get diff prop values

Parameters:

  • plainObj Any
  • [options] Object optional
    • [ignores] Array(String) optional

      prop names to skip checking diff

Returns:

Object:

getFacade

() Facade deprecated

Inherited from Base: /home/ubuntu/base-domain/src/lib/base.coffee:81

Deprecated: just use this.facade

Get facade

Returns:

getModelProps

() ModelProps private

Returns:

getModule

() BaseModule

Get module which this class belongs to

Returns:

getParent

() Function

get parent class

Returns:

Function:

include

(
  • [options]
)
Promise(BaseModel)

include all relational models if not set

Parameters:

  • [options] Object optional
    • [async=true] Boolean optional

      get async values

    • [props] Array(String) optional

      include only given props

Returns:

Promise(BaseModel):

self

included

() Boolean

Check if all subentities are included.

Returns:

Boolean:

inherit

(
  • anotherModel
)
BaseModel

inherit value of anotherModel

Parameters:

Returns:

BaseModel:

this

plainClone

() Object public

clone the model as a plain object

Returns:

Object:

setEnum

(
  • prop
  • value
)
private

set enum value

Parameters:

  • prop String
  • value String | 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:

Object:

plainObject

unset

(
  • prop
)
BaseModel

unset property

Parameters:

  • prop String

    property name

Returns:

BaseModel:

this

Properties

id

String | Number

primary key for the model