wam
w__am 개발노트
wam
  • 분류 전체보기 (165)
    • CS 지식 (10)
      • 자료구조 (0)
      • 알고리즘 (0)
      • 컴퓨터 구조 (0)
      • 운영체제 (0)
      • 네트워크 (7)
      • 데이터베이스 (0)
      • 디자인 패턴 (3)
    • Frontend (131)
      • Three.js (64)
      • NPM (1)
      • Nest.js (19)
      • React (10)
      • Apollo (7)
      • TypeScript (2)
      • JavaScript (12)
      • HTML, CSS (1)
      • Jest (3)
      • E2E (5)
      • Cypress (7)
    • Database (12)
      • TypeORM (12)
    • IT 지식 (8)
      • 클라우드 서비스 (3)
      • 네트워크 (1)
      • 데이터 포맷 (2)
      • 기타 (2)
    • IT Book (2)
    • 유용한 사이트 (1)

블로그 메뉴

  • 홈
  • 태그
  • 방명록
  • 🐱 Github

인기 글

태그

  • react 성능 최적화
  • 초기 환경설정
  • getelapsedtime()
  • Decorators
  • 삼각함수
  • 함수 표현식
  • joi 에러
  • math.cos()
  • 함수 선언문
  • math.sin()
  • 데이터 포맷
  • 디자인 패턴
  • reactive variables
  • 오프-프레미스(off-premise) 방식
  • three.js 구성 요소
  • gridhelper
  • axeshelper
  • threejs 개발 할 때 도움을 줄 수 있는 유틸리티
  • API
  • 원형적인 움직임
  • 함수의 범위
  • Interface
  • isabstract
  • mapped types
  • type-graphql
  • 스코프
  • 함수 리터럴
  • e.preventdefault()
  • getdelta()
  • 렌더링 성능 최적화

최근 글

관리자

글쓰기 / 스킨편집 / 관리자페이지
hELLO · Designed By 정상우.
wam

w__am 개발노트

EntityRepository - deprecated 되었다.
Database/TypeORM

EntityRepository - deprecated 되었다.

2024. 8. 2. 20:38

 

TypeORM 0.3.0 부터 EntityRepository가 deprecated 되었다.

 

 

커스텀 Repository으로 구현하기

https://stackoverflow.com/questions/71557301/how-to-workraound-this-typeorm-error-entityrepository-is-deprecated-use-repo/72533424#72533424

// user.repository.ts
@Injectable()
export class UsersRepository extends Repository<UsersEntity> {
  constructor(private dataSource: DataSource) {
    super(UsersEntity, dataSource.createEntityManager());
  }

  async getById(id: string) {
    return this.findOne({ where: { id } });
  }
  // ...
}

 

 

The repository is then injected into the service.

// user.service.ts
export class UserService {
  constructor(private readonly userRepository: UserRepository) {}

  async getById(id: string): Promise<User> {
    return this.userRepository.getById(id);
  }
  // ...
}

 

 

and the module has imports for the feature and the repository as a provider.

// user.module.ts
@Module({
  imports: [
    TypeOrmModule.forFeature([UserEntity])],
    // ...
  ],
  providers: [UserService, UserRepository],
  // ...
})
export class UserModule {}

 

 

 

저작자표시 변경금지 (새창열림)

'Database > TypeORM' 카테고리의 다른 글

Relations 정리 One-to-One, @JoinColumn()  (0) 2024.08.02
Relations 정리 OneToMany, ManyToOne  (0) 2024.08.02
TypeORM의 Entity  (0) 2024.07.29
TypeORM에서 제공하는 특별한 데코레이터 , 엔티티의 생성 및 수정 일자를 자동으로 관리  (0) 2024.07.29
TypeORM의 Listener  (0) 2024.07.29
    'Database/TypeORM' 카테고리의 다른 글
    • Relations 정리 One-to-One, @JoinColumn()
    • Relations 정리 OneToMany, ManyToOne
    • TypeORM의 Entity
    • TypeORM에서 제공하는 특별한 데코레이터 , 엔티티의 생성 및 수정 일자를 자동으로 관리
    wam
    wam

    티스토리툴바