Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add EntityRepositoryType symbol #698

Merged
merged 1 commit into from Jul 31, 2020
Merged

feat(core): add EntityRepositoryType symbol #698

merged 1 commit into from Jul 31, 2020

Conversation

B4nan
Copy link
Member

@B4nan B4nan commented Jul 31, 2020

This allows to pass the type of your custom repository in the entity definition,
which will be then used in em.getRepository(Entity).

@Entity({ customRepository: () => AuthorRepository })
export class Author {

  [EntityRepositoryType]?: AuthorRepository;

}

const repo = em.getRepository(Author); // repo has type AuthorRepository

Related: #696

This allows to pass the type of your custom repository in the entity definition,
which will be then used in `em.getRepository(Entity)`.

```typescript
@entity({ customRepository: () => AuthorRepository })
export class Author {

  [EntityRepositoryType]?: AuthorRepository;

}

const repo = em.getRepository(Author); // repo has type AuthorRepository
```

Related: #696
@B4nan B4nan merged commit 50d5858 into dev Jul 31, 2020
@B4nan B4nan deleted the type-safe-repo branch July 31, 2020 18:19
B4nan added a commit that referenced this pull request Aug 2, 2020
This allows to pass the type of your custom repository in the entity definition,
which will be then used in `em.getRepository(Entity)`.

```typescript
@entity({ customRepository: () => AuthorRepository })
export class Author {

  [EntityRepositoryType]?: AuthorRepository;

}

const repo = em.getRepository(Author); // repo has type AuthorRepository
```

Related: #696
B4nan added a commit that referenced this pull request Aug 9, 2020
This allows to pass the type of your custom repository in the entity definition,
which will be then used in `em.getRepository(Entity)`.

```typescript
@entity({ customRepository: () => AuthorRepository })
export class Author {

  [EntityRepositoryType]?: AuthorRepository;

}

const repo = em.getRepository(Author); // repo has type AuthorRepository
```

Related: #696
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant