---
lang: en
title: 'API docs: repository.repository_1'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.repository.repository_1.html
---

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

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

## repository() function

Decorator for DefaultCrudRepository generation and injection on properties or method arguments based on the given model and dataSource (or their names)

<b>Signature:</b>

```typescript
export declare function repository(model: string | typeof Entity, dataSource: string | juggler.DataSource): RepositoryDecorator;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  model | <code>string &#124; typeof Entity</code> | Name/class of the model |
|  dataSource | <code>string &#124; juggler.DataSource</code> | Name/instance of the dataSource |

<b>Returns:</b>

`RepositoryDecorator`

## Example


```ts
class CustomerController {
  @repository('Customer', 'mySqlDataSource')
  public custRepo: DefaultCrudRepository<
    Customer,
    typeof Customer.prototype.id
  >;

  constructor(
    @repository(Product, mySqlDataSource)
    public prodRepo: DefaultCrudRepository<
      Product,
      typeof Product.prototype.id
    >,
  ) {}
  // ...
}

```


