Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- component
- JPA
- satisfiles
- 웹애플리케이션서버
- RTK
- typescript
- react-hook-form
- 오블완
- test
- 티스토리챌린지
- go
- javascript
- Gin
- tanstackquery
- springboot
- css
- Spring
- JavaSpring
- storybook
- hook
- java
- React
- Chakra
- Redux
- ReactHooks
- backend
- designpatterns
- golang
- frontend
Archives
- Today
- Total
목록GORM (1)
bkdragon's log
[gorm] 다형성 관계
gorm 에는 다형성 관계라고 하는 아주 막강한 기능을 제공한다.공지사항과 게시글이 있다. 공지사항과 게시글에는 댓글을 달 수 있다. 이럴 때 보통 4개의 테이블을 만들게 된다.NoticeBoardNotice_CommentBoard_Commentgorm 에선 다형성 관계를 통해 하나의 Comment 테이블로 해결할 수 있다!type Comment struct { gorm.Model Content string WriterID uint Writer User OwnerID int // 연관된 모델 ID OwnerType string // 연괸된 모델의 테이블 명이 들어간다.}Comment 모델에 OwnerID 와 OwnerType을 추가하자. Owner 라는 이름은 그냥 ..
golang
2024. 9. 11. 22:33