---
lang: en
title: 'API docs: repository.definecrudrepositoryclass'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/strongloop/loopback-next/tree/master/packages/repository
permalink: /doc/en/lb4/apidocs.repository.definecrudrepositoryclass.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/repository](./repository.md) &gt; [defineCrudRepositoryClass](./repository.definecrudrepositoryclass.md)

## defineCrudRepositoryClass() function

Create (define) an entity CRUD repository class for the given model. This function always uses `DefaultCrudRepository` as the base class, use `defineRepositoryClass` if you want to use your own base repository.

<b>Signature:</b>

```typescript
export declare function defineCrudRepositoryClass<E extends Entity, IdType, Relations extends object>(entityClass: typeof Entity & {
    prototype: E;
}): ModelRepositoryClass<E, DefaultCrudRepository<E, IdType, Relations>>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  entityClass | typeof [Entity](./repository.entity.md) &amp; { prototype: E; } | An entity class such as <code>Product</code>. |

<b>Returns:</b>

[ModelRepositoryClass](./repository.modelrepositoryclass.md)<!-- -->&lt;E, [DefaultCrudRepository](./repository.defaultcrudrepository.md)<!-- -->&lt;E, IdType, Relations&gt;&gt;

## Example


```ts
const ProductRepository = defineCrudRepositoryClass<
  Product,
  typeof Product.prototype.id,
  ProductRelations
>(Product);

```


