So I once followed a tutorial on creating a custom repository using typeorm with the @EntityRepository decorator and now it has been deprecated. Can anyone explain how to do it in typeorm now using nestjs?
please explain it and how to use it, thank you.
In our project we created out custom repository and added our desired methods, (findOneByUUID
, and many others).
Then you should register in your TypeOrmModule
@Injectable()
export class AppointmentRepository extends Repository<Appointment> {
@InjectRepository(Appointment)
appointmentRepository: Repository<Appointment>
constructor(public dataSource: DataSource) {
super(Appointment, dataSource.createEntityManager())
}
findOneByUUID(UUID: string): Promise<Appointment> {
return this.findOneBy({uuid: UUID})
}
}