Compare commits
2 Commits
b547b40410
...
c3ca361506
Author | SHA1 | Date | |
---|---|---|---|
c3ca361506 | |||
63f8902674 |
@ -252,7 +252,7 @@ func GetUserFavoriteWithPagination(ctx context.Context, db *gorm.DB, anthroveUse
|
||||
|
||||
for _, userFavorite := range userFavorites {
|
||||
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 errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, &otterError.NoDataFound{}
|
||||
|
@ -4,9 +4,9 @@ package models
|
||||
type Post struct {
|
||||
BaseModel[AnthrovePostID]
|
||||
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"`
|
||||
References []PostReference `json:"-" gorm:"foreignKey:PostID"`
|
||||
References []PostReference `json:"references" gorm:"foreignKey:PostID"`
|
||||
}
|
||||
|
||||
func (Post) TableName() string {
|
||||
|
Reference in New Issue
Block a user