Entity 구현 - 1: N, N : M 이 강의10분 13초에서
안녕하세요.
위 파일은 product.entity.ts 파일입니다.
product.entity.ts 파일에서 @JoinColumn() 을 productSaleslocation 테이블에만 해주시는 이유가 무엇인지 알 수 있을까요?
product테이블과 서로 관계를 맺고 있는 productSaleslocation 테이블과 users 테이블에도 @JoinColumn()을 해줘야 하는 것 아닌가요?
상품테이블은
productCategory테이블과(상품카테고리_id)ManyToOne 관계를 맺고 있으며,
User 테이블과 (유저_id) ManyToOne 관계를 맺고 있어서 각각 JoinColumn을 해줘야 하는 것으로 생각했는데,
제 생각이 틀린 것일까요?
좋은 강의 해주셔서 진심으로 감사합니다!
답변 1
0
안녕하세요. LI님
@ManyToOne / @OneToMany 관계에서는 @JoinColumn을 생략할 수 있습니다.
해당 부분 노션 학습 자료와 검색을 통하여 부가적인 학습을 진행해 보시길 바랍니다. 감사합니다.
0
그렇군요!
the @JoinColumn decorator can be omitted if you don't need to specify additional information about the join column. By default, TypeORM will automatically create a join column based on the relationship definition.
For example, in the case of a one-to-one relationship between Product and ProductSaleslocation entities, TypeORM will create a foreign key on the Product entity to reference the id column of the ProductSaleslocation entity by default.
However, if you need to specify additional information about the join column, such as the name of the column, you can use the @JoinColumn decorator to define it.
그래프 ql 문서 사용할때 느낌표 남는거 어떻게 없애나요?
0
86
2
강의 전체 소스 코드를 받고싶습니다.
0
77
2
fontawesome 사용 문의
0
81
2
소스 코드 부탁드립니다~
0
87
2
깃 레포지터리 소스
0
87
2
커리큘럼12.css 정렬 에 나오는 과제 정답알고싶어요
0
74
2
10-01 Entity TypeOrmModule.forRoot 에 entities
0
89
3
강의 버전관련 문의입니다
0
104
2
Ubuntu 설치 관련
0
62
1
schema.gql 질문 드립니다.
0
51
1
서버 재실행시 Many to Many
0
102
3
input 관련 문의
0
90
2
Rest API 보다는 graphql이 주된 내용인데
0
134
2
강의 전체 소스코드 받을수있을까요?
0
156
1
도커볼륨 마운트 관련
0
127
2
findOne 타입스크립트오류
0
109
1
http => htrtps 호출 인증서 신뢰 오류
0
356
1
self-signed certificate in certificate chain 에러 발생
0
421
1
mongoose 설치 오류
0
143
1
특정 API, 특정 IP 허용 (단일경로에 CORS 활성화)
0
286
2
08-06
0
180
3
구조랑 패턴 관련해서 질문
0
126
2
mydocker
0
129
2
coolsms statuscode 2000 인데 전송안돼는 경우 확인.
0
156
1





