Integrate users and books
- new table userbook linking users and book - moved rating to users book - updated demo data and tests - updated front to hide routes from non connected users
This commit is contained in:
@@ -6,5 +6,4 @@ type Book struct {
|
||||
gorm.Model
|
||||
Title string `json:"title" gorm:"not null"`
|
||||
Author string `json:"author"`
|
||||
Rating int `json:"rating"`
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import "gorm.io/gorm"
|
||||
|
||||
type User struct {
|
||||
gorm.Model
|
||||
Name string `gorm:"index;uniqueIndex"`
|
||||
Password string
|
||||
Name string `gorm:"index;uniqueIndex"`
|
||||
Password string
|
||||
UserBooks []UserBook
|
||||
}
|
||||
|
||||
12
internal/model/userbook.go
Normal file
12
internal/model/userbook.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package model
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
// describes the relationship between a user and a book.
|
||||
type UserBook struct {
|
||||
gorm.Model
|
||||
UserID uint
|
||||
BookID uint
|
||||
Book Book
|
||||
Rating int
|
||||
}
|
||||
Reference in New Issue
Block a user