arielweinberger / nestjs-recipe

NestJS Best Practices Recipe
MIT License
814 stars 433 forks source link

@EntityRepository is deprecated #43

Open xarielah opened 1 year ago

xarielah commented 1 year ago

This decorator of which using to create custom repositories is deprecated. Please be aware Ariel :)

CaesarBourne commented 1 year ago

create a custom repository like below and use it as the entity repository, passing the entity as an argument

export function CustomRepository(entity: Function): ClassDecorator { return SetMetadata(TYPEORM_EX_CUSTOM_REPOSITORY, entity); }

@CustomRepository(Task) export class TaskRepository extends Repository { constructor(private dataSource: DataSource) { super(Task, dataSource.createEntityManager()); }

mertkaanguzel commented 1 year ago

I tried the solution on the Stackoverflow. It works but it doesn't use EntityRepository or CustomRepositoy decorators.

xwlee commented 10 months ago

https://github.com/xwlee/nestjs-task-management/blob/main/src/tasks/tasks.repository.ts