photoprism/internal/models/album.go

24 lines
541 B
Go
Raw Normal View History

2018-09-16 19:09:40 +02:00
package models
2018-07-18 15:17:56 +02:00
import (
"github.com/jinzhu/gorm"
"github.com/satori/go.uuid"
2018-07-18 15:17:56 +02:00
)
2018-11-06 19:02:03 +01:00
// Photo album
2018-07-18 15:17:56 +02:00
type Album struct {
Model
AlbumUUID string `gorm:"unique_index;"`
AlbumSlug string
AlbumName string
AlbumDescription string `gorm:"type:text;"`
AlbumNotes string `gorm:"type:text;"`
AlbumPhoto *Photo
AlbumPhotoID uint
Photos []Photo `gorm:"many2many:album_photos;"`
2018-07-18 15:17:56 +02:00
}
func (m *Album) BeforeCreate(scope *gorm.Scope) error {
return scope.SetColumn("AlbumUUID", uuid.NewV4().String())
}