package models import ( "github.com/google/uuid" "gorm.io/gorm" "time" ) // Base contains common columns for all tables. type Base struct { UUID uuid.UUID `gorm:"type:uuid;primarykey"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` } func (base *Base) BeforeCreate(tx *gorm.DB) (err error) { base.UUID = uuid.New() return } type ServerSetting struct { Base Name string `json:"name" gorm:"not null"` Description string `json:"description" gorm:"not null"` Value string `json:"value" gorm:"not null"` } type Device struct { Base User User `json:"user" gorm:"ForeignKey:UUID"` Name string `json:"name"` Type string `json:"type"` // Android, iOS, Chrome, FireFox, Edge, etc RefreshKey string `json:"-"` } type User struct { Base Email string `json:"email" gorm:"unique"` Username string `json:"username" gorm:"unique"` FirstName string `json:"first_name"` LastName string `json:"last_name"` AuthType string `json:"auth_type" gorm:"default:Local;not null"` Password string `json:"-"` } type MediaItem struct { Base User User `json:"user" gorm:"ForeignKey:UUID;not null"` EXIFDate time.Time `json:"exif_date"` Latitude string `json:"latitude"` Longitude string `json:"longitude"` MediaType string `json:"media_type" gorm:"default:Photo;not null"` // Photo, Video RelPath string `json:"rel_path" gorm:"not null"` Tags []Tag `json:"tags" gorm:"many2many:media_tags;"` Albums []Album `json:"albums" gorm:"many2many:media_albums;"` } type Tag struct { Base Name string `json:"name" gorm:"not null"` } type Album struct { Base Name string `json:"name" gorm:"not null"` }