BaseSyncRepository Class
sync repository
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:
- 
                    
                        dataObject
- 
                    
                        isUpdateBooleantrue when updating 
Returns:
data
createFromQueryResults
    
        - 
                    
                        params
- 
                    
                        objs
- 
                    
                        [options]
Create model instances from query results
Parameters:
- 
                    
                        paramsObject
- 
                    
                        objsArray(Object)
- 
                    
                        [options]Object optional
Returns:
models
createFromResult
    
        - 
                    
                        obj
- 
                    
                        [options]
Create model instance from result from client
Parameters:
- 
                    
                        objObject
- 
                    
                        [options]Object optional
Returns:
model
delete
    
        - 
                    
                        entity
- 
                    
                        [client=@client]
Destroy the given entity (which must have "id" value)
Parameters:
- 
                    
                        entityEntity
- 
                    
                        [client=@client]ResourceClientInterface optional
Returns:
isDeleted
deprecated
    
        - 
                    
                        methodName
- 
                    
                        message
Show indication message of deprecated method
Parameters:
- 
                    
                        methodNameString
- 
                    
                        messageString
Returns:
error
    
        - 
                    
                        reason
- 
                    
                        [message]
create instance of DomainError
Parameters:
- 
                    
                        reasonStringreason of the error 
- 
                    
                        [message]String optional
Returns:
get
    
        - 
                    
                        id
- 
                    
                        [options]
get object by id.
Parameters:
- 
                    
                        idString | 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:
- 
                    
                        idString | Number
- 
                    
                        [options]Object optional- 
                                
                                    [client=@client]ResourceClientInterface optional
 
- 
                                
                                    
Returns:
entity
getByIds
    
        - 
                    
                        ids
- 
                    
                        [options]
get entities by ID.
Parameters:
- 
                    
                        idsArray(String | Number)
- 
                    
                        [options]Object optional- 
                                
                                    [client=@client]ResourceClientInterface optional
 
- 
                                
                                    
Returns:
entities
getDiff
    
        - 
                    
                        entity
- 
                    
                        [options]
get diff from perpetuation layer
Parameters:
- 
                    
                        entityEntity
- 
                    
                        [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
    
        - 
                    
                        entity
- 
                    
                        [options]
Update or insert a model instance
Parameters:
- 
                    
                        entityEntity | Object
- 
                    
                        [options]Object optional- 
                                
                                    [client=@client]ResourceClientInterface optional
 
- 
                                
                                    
Returns:
entity (the same instance from input, if entity given,)
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
- 
                    
                        [options]
Update set of attributes.
Parameters:
- 
                    
                        idString | Numberof the entity to update 
- 
                    
                        dataObjectkey-value pair to update (notice: this must not be instance of Entity) 
- 
                    
                        [options]Object optional- 
                                
                                    [client=@client]ResourceClientInterface optional
 
- 
                                
                                    
Returns:
updated entity
updateProps
    
        - 
                    
                        entity
- 
                    
                        props
- 
                    
                        [options]
Update set of attributes and returns newly-updated props (other than props)
Parameters:
- 
                    
                        entityEntity
- 
                    
                        propsObjectkey-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
factory
    FactoryInterface
    
    
    
    
    
    factory of the entity.
