BaseRepository Class
Base repository class of DDD pattern. Responsible for perpetuation of models. BaseRepository has a client, which access to data resource (RDB, NoSQL, memory, etc...)
the parent "Base" class just simply gives a @getFacade() method.
Item Index
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:
-
dataObject -
isUpdateBooleantrue when updating
Returns:
data
delete
-
entity -
[client=@client]
Destroy the given entity (which must have "id" value)
Parameters:
-
entityEntity -
[client=@client]ResourceClientInterface optional
Returns:
isDeleted
get
-
id -
[client=@client]
get object by ID.
Parameters:
-
idAny -
[client=@client]ResourceClientInterface optional
Returns:
entity
getById
-
id -
[client=@client]
alias for get()
Parameters:
-
idAny -
[client=@client]ResourceClientInterface optional
Returns:
entity
getModelClass
()
Class
get model class this factory handles
Returns:
query
-
[params] -
[client=@client]
Find all model instances that match params
Parameters:
-
[params]Object optionalquery parameters
-
[client=@client]ResourceClientInterface optional
Returns:
array of entities
save
-
entity -
[client=@client]
Update or insert a model instance
Parameters:
-
entityEntity | Object -
[client=@client]ResourceClientInterface optional
Returns:
entity (the same instance from input, if entity given,)
singleQuery
-
[params] -
[client=@client]
Find one model instance that matches params, Same as query, but limited to one result
Parameters:
-
[params]Object optionalquery parameters
-
[client=@client]ResourceClientInterface optional
Returns:
entity
update
-
id -
data -
[client=@client]
Update set of attributes.
Parameters:
-
idAnyid of the entity to update
-
dataObjectkey-value pair to update (notice: this must not be instance of Entity)
-
[client=@client]ResourceClientInterface optional
Returns:
updated entity
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
modelName
String
protected
static
model name to handle
