photoprism/internal/entity/event.go

37 lines
1 KiB
Go
Raw Normal View History

package entity
2019-06-17 07:19:44 +02:00
import (
"time"
"github.com/jinzhu/gorm"
"github.com/photoprism/photoprism/pkg/rnd"
2019-06-17 07:19:44 +02:00
)
// Event defines temporal event that can be used to link photos together
2019-06-17 07:19:44 +02:00
type Event struct {
EventUUID string `gorm:"type:varbinary(36);unique_index;"`
EventSlug string `gorm:"type:varbinary(128);unique_index;"`
2019-06-17 07:19:44 +02:00
EventName string
EventType string
EventDescription string `gorm:"type:text;"`
EventNotes string `gorm:"type:text;"`
EventBegin time.Time `gorm:"type:datetime;"`
EventEnd time.Time `gorm:"type:datetime;"`
2019-06-17 07:19:44 +02:00
EventLat float64
EventLng float64
2019-06-17 07:19:44 +02:00
EventDist float64
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
}
// TableName returns Event table identifier "events"
2019-06-17 07:19:44 +02:00
func (Event) TableName() string {
return "events"
}
// BeforeCreate computes a random UUID when a new event is created in database
2019-06-17 07:19:44 +02:00
func (e *Event) BeforeCreate(scope *gorm.Scope) error {
return scope.SetColumn("EventUUID", rnd.PPID('e'))
2019-06-17 07:19:44 +02:00
}