photoprism/internal/models/album.go
2019-06-17 21:45:06 +02:00

24 lines
592 B
Go

package models
import (
"github.com/jinzhu/gorm"
uuid "github.com/satori/go.uuid"
)
// Photo album
type Album struct {
Model
AlbumUUID string `gorm:"unique_index;"`
AlbumSlug string `gorm:"unique_index;"`
AlbumName string
AlbumDescription string `gorm:"type:text;"`
AlbumNotes string `gorm:"type:text;"`
AlbumPhoto *Photo
AlbumPhotoID uint
AlbumFavorite bool
Photos []Photo `gorm:"many2many:album_photos;"`
}
func (m *Album) BeforeCreate(scope *gorm.Scope) error {
return scope.SetColumn("AlbumUUID", uuid.NewV4().String())
}