250x250
Notice
Recent Posts
Recent Comments
Link
«   2025/08   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Archives
Today
Total
관리 메뉴

devlog_owen

240102 [TIL] nest.js,typescript 개인프로젝트 과제 오류정리 본문

TIL

240102 [TIL] nest.js,typescript 개인프로젝트 과제 오류정리

developer_owen 2024. 1. 3. 02:21
728x90

1. findOne 메서드에 잘못된 인자가 전달되었을때

"[nestjs/typeorm] Object literal may only specify known properties, and 'id' does not exist in type 'FindOneOptions'"

 

이 오류는 findOne 메서드에 잘못된 인자가 전달되었을 때 발생합니다. findOne 메서드는 FindOneOptions 타입의 객체를 인자로 받아야 하는데, id라는 프로퍼티는 FindOneOptions 타입에 존재하지 않습니다. 이 오류를 해결하려면 findOne 메서드에 올바른 형식의 인자를 전달해야 합니다.

예를 들어, { where: { id: createBookingDto.eventId } }와 같은 형태로 전달하면 된다.

 

 


Repository의 의존성을 해결할 수 없을 때

"Nest can't resolve dependencies of the BookingService (BookingRepository, ?). Please make sure that the argument "EventRepository" at index [1] is available in the BookingModule context."

 

 

이 오류는 BookingService가 EventRepository의 의존성을 해결할 수 없을 때 발생합니다.  BookingModule에 EventRepository가 제공되지 않았기 때문이다. 이 오류를 해결하려면, BookingModule에 Event 엔티티를 import해야 합니다. 이를 위해 TypeOrmModule.forFeature 메서드를 사용하여 BookingModule에 Event 엔티티를 추가하면 됩니다.

@Module({
  imports: [TypeOrmModule.forFeature([Booking, UserModule, Event])],
  providers: [BookingService],
  controllers: [BookingController],
})
export class BookingModule {}

 

728x90