---
lang: en
title: 'API docs: repository.definekeyvaluerepositoryclass'
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.definekeyvaluerepositoryclass.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/repository](./repository.md) &gt; [defineKeyValueRepositoryClass](./repository.definekeyvaluerepositoryclass.md)

## defineKeyValueRepositoryClass() function

Create (define) a KeyValue repository class for the given entity. This function always uses `DefaultKeyValueRepository` as the base class, use `defineRepositoryClass` if you want to use your own base repository.

<b>Signature:</b>

```typescript
export declare function defineKeyValueRepositoryClass<M extends Model>(modelClass: typeof Model & {
    prototype: M;
}): ModelRepositoryClass<M, DefaultKeyValueRepository<M>>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  modelClass | typeof [Model](./repository.model.md) &amp; { prototype: M; } | An entity class such as <code>Product</code>. |

<b>Returns:</b>

[ModelRepositoryClass](./repository.modelrepositoryclass.md)<!-- -->&lt;M, [DefaultKeyValueRepository](./repository.defaultkeyvaluerepository.md)<!-- -->&lt;M&gt;&gt;

## Example


```ts
const ProductKeyValueRepository = defineKeyValueRepositoryClass(Product);

```


