This repository has been archived on 2023-11-13. You can view files and clone it, but cannot push or open issues or pull requests.
imagini/internal/models/db.go
2021-01-16 17:00:17 -05:00

56 lines
1.7 KiB
Go

package models
import (
"gorm.io/gorm"
"time"
)
// Might not even need this
type ServerSetting struct {
gorm.Model
Name string `json:"name" gorm:"not null"`
Description string `json:"description" gorm:"not null"`
Value string `json:"value" gorm:"not null"`
}
type Device struct {
gorm.Model
User User `json:"user" gorm:"ForeignKey:ID"`
DeviceName string `json:"name"`
Type string `json:"type"` // Android, iOS, Chrome, FireFox, Edge, etc
}
// TODO: ID -> UUID?
type User struct {
gorm.Model
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:"-"`
JWTSecret string `json:"-" gorm:"unique;not null"` // TODO: Auto Generate UUID
}
type MediaItem struct {
gorm.Model
User User `json:"user" gorm:"ForeignKey:ID;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 {
gorm.Model
Name string `json:"name" gorm:"not null"`
}
type Album struct {
gorm.Model
Name string `json:"name" gorm:"not null"`
}