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...)
Item Index
Methods
Methods
appendTimeStamp
-
data
-
isUpdate
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
Booleantrue when updating
Returns:
data
createFromQueryResults
-
params
-
objs
-
[options]
Create model instances from query results
Parameters:
-
params
Object -
objs
Array(Object) -
[options]
Object optional
Returns:
models
createFromResult
-
obj
-
[options]
Create model instance from result from client
Parameters:
-
obj
Object -
[options]
Object optional
Returns:
model
delete
-
entity
-
[client=@client]
Destroy the given entity (which must have "id" value)
Parameters:
-
entity
Entity -
[client=@client]
ResourceClientInterface optional
Returns:
isDeleted
deprecated
-
methodName
-
message
Show indication message of deprecated method
Parameters:
-
methodName
String -
message
String
Returns:
error
-
reason
-
[message]
create instance of DomainError
Parameters:
-
reason
Stringreason of the error
-
[message]
String optional
Returns:
get
-
id
-
[options]
get object by id.
Parameters:
-
id
String | Number -
[options]
Object optional-
[client=@client]
ResourceClientInterface optional
-
Returns:
entity
getAll
()
Array(Entity)
get all entities
Returns:
array of entities
getById
-
id
-
[options]
alias for get()
Parameters:
-
id
String | Number -
[options]
Object optional-
[client=@client]
ResourceClientInterface optional
-
Returns:
entity
getByIds
-
ids
-
[options]
get entities by ID.
Parameters:
-
ids
Array(String | Number) -
[options]
Object optional-
[client=@client]
ResourceClientInterface optional
-
Returns:
entities
getDiff
-
entity
-
[options]
get diff from perpetuation layer
Parameters:
-
entity
Entity -
[options]
Object optional-
[client=@client]
ResourceClientInterface optional
-
Returns:
diff
getModelClass
()
Class
get model class this factory handles
Returns:
getParent
()
Function
get parent class
Returns:
query
-
[params]
-
[options]
Find all model instances that match params
Parameters:
-
[params]
Object optionalquery parameters
-
[options]
Object optional-
[client=@client]
ResourceClientInterface optional
-
Returns:
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]
Find one model instance that matches params, Same as query, but limited to one result
Parameters:
-
[params]
Object optionalquery parameters
-
[options]
Object optional-
[client=@client]
ResourceClientInterface optional
-
Returns:
entity
update
-
id
-
data
-
[client=@client]
Update set of attributes.
Parameters:
-
id
String | Numberof the entity to update
-
data
Objectkey-value pair to update (notice: this must not be instance of Entity)
-
[client=@client]
ResourceClientInterface optional
Returns:
updated entity
updateProps
-
entity
-
props
-
[options]
Update set of attributes and returns newly-updated props (other than props
)
Parameters:
-
entity
Entity -
props
Objectkey-value pair to update (notice: this must not be instance of Entity)
-
[options]
Object optional-
[client=@client]
ResourceClientInterface optional
-
Returns:
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.