API Docs for:
Show:

MasterRepository Class

Master repository: handling static data Master data are loaded from master-data directory (by default, it's facade.dirname + /master-data) These data should be formatted in Fixture. Master data are read-only, so 'save', 'update' and 'delete' methods are not available. (And currently, 'query' and 'singleQuery' are also unavailable as MemoryResource does not support them yet...)

Methods

appendTimeStamp

(
  • data
  • isUpdate
)
Object protected

add createdAt, updatedAt to given data

  • createdAt will not be overriden if already set.
  • updatedAt will be overriden for each time

Parameters:

  • data Object
  • isUpdate Boolean

    true when updating

Returns:

Object:

data

createFromQueryResults

(
  • params
  • objs
  • [options]
)
Array(BaseModel) protected

Create model instances from query results

Parameters:

  • params Object
  • objs Array(Object)
  • [options] Object optional

Returns:

Array(BaseModel):

models

createFromResult

(
  • obj
  • [options]
)
BaseModel protected

Create model instance from result from client

Parameters:

  • obj Object
  • [options] Object optional

Returns:

BaseModel:

model

delete

(
  • entity
  • [client=@client]
)
Boolean public

Destroy the given entity (which must have "id" value)

Parameters:

Returns:

Boolean:

isDeleted

deprecated

(
  • methodName
  • message
)
Error protected

Show indication message of deprecated method

Parameters:

  • methodName String
  • message String

Returns:

Error:

error

(
  • reason
  • [message]
)
Error

create instance of DomainError

Parameters:

  • reason String

    reason of the error

  • [message] String optional

Returns:

Error:

get

(
  • id
  • [options]
)
Entity public

get object by id.

Parameters:

Returns:

Entity:

entity

getAll

() Array(Entity)

get all entities

Returns:

Array(Entity):

array of entities

getById

(
  • id
  • [options]
)
Entity public

alias for get()

Parameters:

Returns:

Entity:

entity

getByIds

(
  • ids
  • [options]
)
Array(Entity) public

get entities by ID.

Parameters:

Returns:

Array(Entity):

entities

getDiff

(
  • entity
  • [options]
)
Object public

get diff from perpetuation layer

Parameters:

Returns:

Object:

diff

getFacade

() Facade deprecated

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

Deprecated: just use this.facade

Get facade

Returns:

getModelClass

() Class

get model class this factory handles

Returns:

Class:

getModule

() BaseModule

Get module which this class belongs to

Returns:

getParent

() Function

get parent class

Returns:

Function:

query

(
  • [params]
  • [options]
)
Array(Entity) public

Find all model instances that match params

Parameters:

  • [params] Object optional

    query parameters

  • [options] Object optional

Returns:

Array(Entity):

array of entities

save

() public

Update or insert a model instance Save data with "fixtureInsertion" option. Otherwise throw an error.

setRoot

() protected

singleQuery

(
  • [params]
  • [options]
)
Entity | public

Find one model instance that matches params, Same as query, but limited to one result

Parameters:

  • [params] Object optional

    query parameters

  • [options] Object optional

Returns:

Entity | :

entity

update

(
  • id
  • data
  • [client=@client]
)
Entity public

Update set of attributes.

Parameters:

  • id String | Number

    of the entity to update

  • data Object

    key-value pair to update (notice: this must not be instance of Entity)

  • [client=@client] ResourceClientInterface optional

Returns:

Entity:

updated entity

updateProps

(
  • entity
  • props
  • [options]
)
Object public

Update set of attributes and returns newly-updated props (other than props)

Parameters:

  • entity Entity
  • props Object

    key-value pair to update (notice: this must not be instance of Entity)

  • [options] Object optional

Returns:

Object:

updated props

Properties

client

ResourceClientInterface protected

client accessing to data resource (RDB, NoSQL, memory, etc...)

mock object is input by default. Extenders must set this property to achieve perpetuation

dataName

String static

Name of the data in master data.