Proof of concept for variable album covers - GQL playground working.
This commit is contained in:
parent
193e05e7e0
commit
6408b2c0d0
|
@ -17,7 +17,7 @@ type Album struct {
|
||||||
Owners []User `gorm:"many2many:user_albums;constraint:OnDelete:CASCADE;"`
|
Owners []User `gorm:"many2many:user_albums;constraint:OnDelete:CASCADE;"`
|
||||||
Path string `gorm:"not null"`
|
Path string `gorm:"not null"`
|
||||||
PathHash string `gorm:"unique"`
|
PathHash string `gorm:"unique"`
|
||||||
CoverID int `gorm:"index;default:-1;"`
|
CoverID int `gorm:"index;default:-1;"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Album) FilePath() string {
|
func (a *Album) FilePath() string {
|
||||||
|
|
|
@ -174,7 +174,6 @@ func (r *albumResolver) Thumbnail(ctx context.Context, obj *models.Album) (*mode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// err := r.Database.Raw(`
|
// err := r.Database.Raw(`
|
||||||
// WITH recursive sub_albums AS (
|
// WITH recursive sub_albums AS (
|
||||||
// SELECT * FROM albums AS root WHERE id = ?
|
// SELECT * FROM albums AS root WHERE id = ?
|
||||||
|
@ -289,8 +288,6 @@ func (r *mutationResolver) SetAlbumCoverID(ctx context.Context, albumID int, cov
|
||||||
return nil, errors.New("forbidden")
|
return nil, errors.New("forbidden")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if err := r.Database.Model(&album).Update("cover_id", coverID).Error; err != nil {
|
if err := r.Database.Model(&album).Update("cover_id", coverID).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue