본문 바로가기

bkdragon's log

검색하기
bkdragon's log
프로필사진 bkdragon

  • 분류 전체보기 (91)
    • Typescript (14)
    • React (32)
    • Java Spring (5)
    • Flutter (0)
    • concept (22)
    • Thinking (2)
    • Error (1)
    • UI UX (7)
    • golang (7)
    • 이펙티브 타입스크립트 (1)
Guestbook
Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
일 월 화 수 목 금 토
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
Tags
  • Spring
  • Chakra
  • golang
  • tanstackquery
  • component
  • JavaSpring
  • satisfiles
  • frontend
  • 오블완
  • Redux
  • storybook
  • test
  • css
  • Gin
  • designpatterns
  • typescript
  • JPA
  • React
  • javascript
  • 웹애플리케이션서버
  • springboot
  • react-hook-form
  • backend
  • ReactHooks
  • google
  • 티스토리챌린지
  • go
  • java
  • RTK
  • hook
more
Archives
Today
Total
관리 메뉴
  • 글쓰기
  • 방명록
  • RSS
  • 관리

목록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
이전 Prev 1 Next 다음

Blog is powered by kakao / Designed by Tistory

티스토리툴바