Page Contents

Home > @loopback/repository > DefaultCrudRepository

DefaultCrudRepository class

Default implementation of CRUD repository using legacy juggler model and data source

Signature:

export declare class DefaultCrudRepository<T extends Entity, ID, Relations extends object = {}> implements EntityCrudRepository<T, ID, Relations> 

Constructors

Constructor Modifiers Description
(constructor)(entityClass, dataSource)   Constructor of DefaultCrudRepository

Properties

Property Modifiers Type Description
dataSource   juggler.DataSource  
entityClass   typeof Entity & {
prototype: T;
}
 
inclusionResolvers   Map<string, InclusionResolver<T, Entity>>  
modelClass   juggler.PersistedModelClass  

Methods

Method Modifiers Description
_createBelongsToAccessorFor(relationName, targetRepoGetter)    
_createHasManyRepositoryFactoryFor(relationName, targetRepoGetter)    
_createHasOneRepositoryFactoryFor(relationName, targetRepoGetter)    
count(where, options)    
create(entity, options)    
createAll(entities, options)    
createBelongsToAccessorFor(relationName, targetRepoGetter)   Function to create a belongs to accessor
createHasManyRepositoryFactoryFor(relationName, targetRepoGetter)   Function to create a constrained relation repository factory
createHasOneRepositoryFactoryFor(relationName, targetRepoGetter)   Function to create a constrained hasOne relation repository factory
delete(entity, options)    
deleteAll(where, options)    
deleteById(id, options)    
ensurePersistable(entity, options)   Converts an entity object to a JSON object to check if it contains navigational property. Throws an error if entity contains navigational property.
entityToData(entity, options)   This function works as a persist hook. It converts an entity from the CRUD operations’ caller to a persistable data that can will be stored in the back-end database.User can extend DefaultCrudRepository then override this function to execute custom persist hook.
execute(command, parameters, options)    
exists(id, options)    
find(filter, options)    
findById(id, filter, options)    
findOne(filter, options)    
includeRelatedModels(entities, include, options)   Returns model instances that include related models of this repository that have a registered resolver.
normalizeFilter(filter)   Removes juggler’s “include” filter as it does not apply to LoopBack 4 relations.
registerInclusionResolver(relationName, resolver)   Register an inclusion resolver for the related model name.
replaceById(id, data, options)    
save(entity, options)    
toEntities(models)    
toEntity(model)    
update(entity, options)    
updateAll(data, where, options)    
updateById(id, data, options)