API Docs for:
Show:

BaseSyncRepository Class

sync repository

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

(
  • entity
  • [options]
)
Entity public

Update or insert a model instance

Parameters:

Returns:

Entity:

entity (the same instance from input, if entity given,)

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
  • [options]
)
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)

  • [options] Object 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