diff --git a/inits/Models.go b/inits/Models.go index d6a25a3..8bae4d2 100755 --- a/inits/Models.go +++ b/inits/Models.go @@ -24,6 +24,7 @@ func Models() { mustRun(DB.AutoMigrate(&models.Setting{})) mustRun(DB.AutoMigrate(&models.SystemResource{})) mustRun(DB.AutoMigrate(&models.Tag{})) + mustRun(DB.AutoMigrate(&models.TagLinks{})) } func mustRun(err error) { diff --git a/models/Link.go b/models/Link.go index eb8d624..494fcea 100755 --- a/models/Link.go +++ b/models/Link.go @@ -10,7 +10,7 @@ type Link struct { UserID uint `json:"-"` ParentFolder *Folder `json:"-"` ParentFolderID uint - Tags []Tag `gorm:"many2many:links_tags;"` + Tags []*Tag `gorm:"many2many:tag_links;"` } type LinkListValidation struct { diff --git a/models/Tag.go b/models/Tag.go index dd5de42..8dc8525 100644 --- a/models/Tag.go +++ b/models/Tag.go @@ -1,11 +1,24 @@ package models +import ( + "time" + + "gorm.io/gorm" +) + type Tag struct { Model - Name string `gorm:"size:128;"` - Links []Link `gorm:"many2many:links_tags;"` - UserId uint `gorm:"index"` - User User + Name string `gorm:"size:128;"` + UserId uint `gorm:"index" json:"-"` + User User `json:"-"` + Links []*Link `gorm:"many2many:tag_links;" json:"-"` +} + +type TagLinks struct { + LinkID uint `gorm:"primaryKey"` + TagID uint `gorm:"primaryKey"` + CreatedAt time.Time + DeletedAt gorm.DeletedAt } type TagCreateValidation struct {