Page Contents

Home > @loopback/repository > CrudRepositoryImpl

CrudRepositoryImpl class

Repository implementation


export declare class CrudRepositoryImpl<T extends Entity, ID> implements EntityCrudRepository<T, ID> 

Implements: EntityCrudRepository<T, ID>


User can import CrudRepositoryImpl and call its functions like: CrudRepositoryImpl.find(somefilters, someoptions)

Or extend class CrudRepositoryImpl and override its functions:

export class TestRepository extends CrudRepositoryImpl<Test> {
  constructor(dataSource: DataSource, model: Test) {
    super(dataSource, Customer);

  // Override `deleteAll` to disable the operation
  deleteAll(where?: Where, options?: Options) {
    return Promise.reject(new Error('deleteAll is disabled'));


Constructor Modifiers Description
(constructor)(dataSource, entityClass)   Constructs a new instance of the CrudRepositoryImpl class


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


Method Modifiers Description
count(where, options)    
create(entity, options)    
createAll(entities, options)    
delete(entity, options)    
deleteAll(where, options)    
deleteById(id, options)    
execute(command, parameters, options)    
exists(id, options)    
find(filter, options)    
findById(id, filter, options)    
replaceById(id, data, options)    
save(entity, options)    
update(entity, options)    
updateAll(data, where, options)    
updateById(id, data, options)