File tree 2 files changed +7
-6
lines changed
2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 1
1
package entity
2
2
3
3
type User struct {
4
- ID uint64 `gorm:"primary_key:auto_increment" json:"id"`
5
- Name string `gorm:"type:varchar(255)" json:"name"`
6
- Email string `gorm:"type:varchar(255);unique" json:"email"`
7
- Password string `gorm:"->;<-;not null" json:"-"`
8
- Token string `gorm:"-" json:"token,omitempty"`
4
+ ID uint64 `gorm:"primary_key:auto_increment" json:"id"`
5
+ Name string `gorm:"type:varchar(255)" json:"name"`
6
+ Email string `gorm:"type:varchar(255);unique" json:"email"`
7
+ Password string `gorm:"->;<-;not null" json:"-"`
8
+ Token string `gorm:"-" json:"token,omitempty"`
9
+ Books * []Book `json:"books,omitempty"`
9
10
}
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ func (db *userConnection) UpdateUser(user entity.User) entity.User {
48
48
49
49
func (db * userConnection ) GetUser (userID string ) entity.User {
50
50
var user entity.User
51
- db .connection .Find (& user , userID )
51
+ db .connection .Preload ( "Books.User" ). Find (& user , userID )
52
52
return user
53
53
}
54
54
You can’t perform that action at this time.
0 commit comments