Compare commits

..

2 Commits

Author SHA1 Message Date
c3ca361506 feat: added references in posts
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-07-15 15:37:21 +02:00
63f8902674 feat: removed tags & added references for posts
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-07-15 15:24:08 +02:00
2 changed files with 3 additions and 3 deletions

View File

@ -252,7 +252,7 @@ func GetUserFavoriteWithPagination(ctx context.Context, db *gorm.DB, anthroveUse
for _, userFavorite := range userFavorites { for _, userFavorite := range userFavorites {
var post models.Post var post models.Post
err = db.WithContext(ctx).Model(&models.Post{}).Where("id = ?", userFavorite.PostID).First(&post).Error err = db.WithContext(ctx).Model(&models.Post{}).Joins("References").Where("id = ?", userFavorite.PostID).First(&post).Error
if err != nil { if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, &otterError.NoDataFound{} return nil, &otterError.NoDataFound{}

View File

@ -4,9 +4,9 @@ package models
type Post struct { type Post struct {
BaseModel[AnthrovePostID] BaseModel[AnthrovePostID]
Rating Rating `json:"rating" gorm:"type:enum('safe','questionable','explicit')"` Rating Rating `json:"rating" gorm:"type:enum('safe','questionable','explicit')"`
Tags []Tag `json:"tags" gorm:"many2many:post_tags;"` Tags []Tag `json:"-" gorm:"many2many:post_tags;"`
Favorites []UserFavorites `json:"-" gorm:"foreignKey:PostID"` Favorites []UserFavorites `json:"-" gorm:"foreignKey:PostID"`
References []PostReference `json:"-" gorm:"foreignKey:PostID"` References []PostReference `json:"references" gorm:"foreignKey:PostID"`
} }
func (Post) TableName() string { func (Post) TableName() string {