LoopbackRepository Class
Item Index
Methods
- appendTimeStamp
- count
- createFromQueryResults
- createFromResult
- delete
- deprecated
- error
- get
- getAll
- getById
- getByIds
- getClientByEntity
- getClientByForeignKey
- getClientByQuery
- getDiff
- getFacade deprecated
- getLbModelName static
- getModelClass
- getModule
- getParent
- getRelatedClient
- modifyDate
- parseSessionId
- query
- save
- setRoot
- singleQuery
- update
- updateProps
Properties
- client
- factory
- lbModelName static
- props static
- root
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
count
    
        - 
                    
                        [where]
Return the number of models that match the optional "where" filter.
Parameters:
- 
                    
                        [where]Object optional
Returns:
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
- 
                    
                        [options]
Destroy the given entity (which must have "id" value)
Parameters:
- 
                    
                        entityEntity
- 
                    
                        [options]Object 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 entity by id.
Parameters:
- 
                    
                        idString | Number
- 
                    
                        [options]Object optional- 
                                
                                    [foreignKey]String optional
 
- 
                                
                                    
Returns:
entity
getAll
    
        ()
    
    
        
            Promise(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
Returns:
entities
getClientByEntity
    
        - 
                    
                        entity
get client by entity. By default it returns @client
Parameters:
- 
                    
                        entityEntity | Object
Returns:
client
getClientByForeignKey
    
        - 
                    
                        foreignKey
get client by foreign key. By default it returns @client
Parameters:
- 
                    
                        foreignKeyString
Returns:
client
getClientByQuery
    
        - 
                    
                        query
get client by query value. By default it returns @client
Parameters:
- 
                    
                        queryObject
Returns:
client
getDiff
    
        - 
                    
                        entity
- 
                    
                        [options]
get diff from perpetuation layer
Parameters:
- 
                    
                        entityEntity
- 
                    
                        [options]Object optional- 
                                
                                    [client=@client]ResourceClientInterface optional
 
- 
                                
                                    
Returns:
diff
getLbModelName
    
        ()
    
    
        
            String
        
    
    
    
    
    
        static
    
    
    
    
    get model name used in LoopBack
Returns:
getModelClass
    
        ()
    
    
        
            Class
        
    
    
    
    
    
    
    
    
    get model class this factory handles
Returns:
getParent
    
        ()
    
    
        
            Function
        
    
    
    
    
    
    
    
    
    get parent class
Returns:
getRelatedClient
    
        - 
                    
                        params
Get loopback-related-client
Parameters:
- 
                    
                        paramsObject- 
                                
                                    modelNameStringforeign model name 
- 
                                
                                    idStringforeign id 
- 
                                
                                    [relation]String optionalrelation name 
- 
                                
                                    [foreignKey]String optionalforeign key prop. 
- 
                                
                                    [through]String optional
- 
                                
                                    [keyThrough]String optional
 
- 
                                
                                    
Returns:
modifyDate
    
        - 
                    
                        data
convert 'date' type property for loopback format
Parameters:
- 
                    
                        dataEntity | Object
parseSessionId
    
        - 
                    
                        sessionId
get accessToken and userId by sessionId
Parameters:
- 
                    
                        sessionIdString
Returns:
[accessToken, userId]
query
    
        - 
                    
                        [params]
- 
                    
                        [options]
Find all model instances that match params
Parameters:
- 
                    
                        [params]Object optionalquery parameters 
- 
                    
                        [options]Object optional
Returns:
array of entities
save
    
        - 
                    
                        entity
- 
                    
                        [options]
Update or insert a model instance
Parameters:
- 
                    
                        entityEntity | Object
- 
                    
                        [options]Object 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
Returns:
entity
update
    
        - 
                    
                        id
- 
                    
                        data
- 
                    
                        [options]
Update set of attributes.
Parameters:
- 
                    
                        idAnyid of the entity to update 
- 
                    
                        dataObjectkey-value pair to update 
- 
                    
                        [options]Object optional
Returns:
updated entity
updateProps
    
        - 
                    
                        entity
- 
                    
                        data
- 
                    
                        [options]
Update set of attributes and returns newly-updated props (other than props)
Parameters:
- 
                    
                        entityEntity
- 
                    
                        dataObjectkey-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.
lbModelName
    String
    
    
    
    
        static
    
    
    model name used in Loopback it will be the same value as @modelName if not set
props
    Object
    
    
    
    
        static
    
    
    Map to convert loopback's object prop into model prop
key: loopback's prop value: model prop
if value is null or undefined, the property only exists in loopback and is removed from the created model.
