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

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

[Home](./index.md) &gt; [@loopback/repository](./repository.md) &gt; [defineModelClass](./repository.definemodelclass.md)

## defineModelClass() function

Create (define) a new model class with the given name and definition.

Example usage:

```ts
const Product = defineModelClass(Entity, new ModelDefinition('Product'));

```
To enable type safety, you should describe properties of your model:

```ts
const Product = defineModelClass<
 typeof Entity,
 {id: number, name: string}
>(Entity, new ModelDefinition('Product'));

```
If your model allows arbitrary (free-form) properties, then add `AnyObject` to the type describing model properties.

```ts
const Product = defineModelClass<
 typeof Entity,
 AnyObject & {id: number},
>(Entity, new ModelDefinition('Product'));

```

<b>Signature:</b>

```typescript
export declare function defineModelClass<BaseCtor extends typeof Model, Props extends object = {}>(base: BaseCtor, definition: ModelDefinition): DynamicModelCtor<BaseCtor, Props>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  base | <code>BaseCtor</code> |  |
|  definition | <code>ModelDefinition</code> |  |

<b>Returns:</b>

`DynamicModelCtor<BaseCtor, Props>`


