model

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoSuchCamera = errors.New("No such Photo Id")
View Source
var NoSuchPhoto = errors.New("No such Photo Id")
View Source
var Version = "development"

Functions

func UpgradeDb

func UpgradeDb(db *DB) error

Types

type Album

type Album struct {
	Id          int    `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	CoverPic    string `json:"coverPic"`
}

type AlbumStore

type AlbumStore interface {
	AddAlbum(name, description, coverpic string) (*Album, error)
	Album(id int) (*Album, error)
	Albums() ([]*Album, error)
	AlbumPhotos(albumId int, filter PhotoFilter) ([]*Photo, error)
	//CameraAlbums() ([]*Album, error)
	//CameraAlbum(cameraModel string) (*Album, error)
	CreateAlbumStore() error
	DeleteAlbum(id int) error
	DeleteAlbumStore() error
	HasAlbum(id int) bool
	HasAlbumName(name string) bool
	PhotoAlbums(photoId string) ([]*Album, error)
	UpdateAlbum(album *Album) (*Album, error)
	UpdatePhotoAlbums(albumIds []int, photoId string) error
}

type Camera

type Camera struct {
	Id                 string  `json:"id"`
	Model              string  `json:"model"`
	Make               string  `json:"make"`
	Year               int     `json:"year"`
	EffectivePixels    int     `json:"effectivePixels"`
	TotalPixels        int     `json:"totalPixels"`
	SensorSize         string  `json:"sensorSize"`
	SensorType         string  `json:"sensorType"`
	SensorResolution   string  `json:"sensorResolution"`
	ImageResolution    string  `json:"imageResolution"`
	CropFactor         float32 `json:"cropFactor"`
	OpticalZoom        float32 `json:"opticalZoom"`
	DigitalZoom        bool    `json:"digitalZoom"`
	Iso                string  `json:"iso"`
	Raw                bool    `json:"raw"`
	ManualFocus        bool    `json:"manualFocus"`
	FocusRange         int     `json:"focusRange"`
	MacroFocusRange    int     `json:"macroFocusRange"`
	FocalLengthEquiv   string  `json:"focalLengthEquiv"`
	AperturePriority   bool    `json:"aperturePriority"`
	MaxAperture        string  `json:"maxAperture"`
	MaxApertureEquiv   string  `json:"maxApertureEquiv"`
	Metering           string  `json:"metering"`
	ExposureComp       string  `json:"exposureComp"`
	ShutterPriority    bool    `json:"shutterPriority"`
	MinShutterSpeed    string  `json:"minShutterSpeed"`
	MaxShutterSpeed    string  `json:"maxShutterSpeed"`
	BuiltInFlash       bool    `json:"builtInFlash"`
	ExternalFlash      bool    `json:"externalFlash"`
	ViewFinder         string  `json:"viewFinder"`
	VideoCapture       bool    `json:"videoCapture"`
	MaxVideoResolution string  `json:"maxVideoResolution"`
	Gps                bool    `json:"gps"`
	Image              string  `json:"image"`
}

type CameraStore

type CameraStore interface {
	AddCamera(camera *Camera) error
	AddCameraFromPhoto(photo *Photo) error
	CreateCameraStore() error
	Camera(id string) (*Camera, error)
	Cameras() ([]*Camera, error)
	DeleteCamera(id string) (bool, error)
	DeleteCameraStore() error
	HasCamera(id string) bool
	HasCameraModel(model string) bool
	PopulateFromPhotos() error
	UpdateCamera(camera *Camera) (*Camera, error)
	UpdateCameraImage(img, id string) (*Camera, error)
}

type Comment

type Comment struct {
	Id    int    `json:"id"`
	Guest string `json:"guest"`

	Time time.Time `json:"time"`
	Body string    `json:"body"`
	// contains filtered or unexported fields
}

type CommentStore

type CommentStore interface {
	CreateCommentStore() error
	DeleteCommentStore() error
	AddComment(guestId uuid.UUID, driveId string, body string) (*Comment, error)
	PhotoComments(driveId string) ([]*Comment, error)
}

type DB

type DB struct {
	*sql.DB
}

func (*DB) AddAlbum

func (db *DB) AddAlbum(name, description, coverpic string) (*Album, error)

func (*DB) AddCamera

func (db *DB) AddCamera(c *Camera) error

func (*DB) AddCameraFromPhoto

func (db *DB) AddCameraFromPhoto(p *Photo) error

func (*DB) AddComment

func (db *DB) AddComment(guestId uuid.UUID, driveId string, body string) (*Comment, error)

func (*DB) AddGuest

func (db *DB) AddGuest(uuid uuid.UUID, g *Guest) error

func (*DB) AddLike

func (db *DB) AddLike(uuid uuid.UUID, driveId string) error

func (*DB) AddPhoto

func (db *DB) AddPhoto(p *Photo, exif *mexif.ExifCompact) error

func (*DB) Album

func (db *DB) Album(id int) (*Album, error)

func (*DB) AlbumPhotos

func (db *DB) AlbumPhotos(albumId int, filter PhotoFilter) ([]*Photo, error)

func (*DB) Albums

func (db *DB) Albums() ([]*Album, error)

func (*DB) Camera

func (db *DB) Camera(id string) (*Camera, error)

func (*DB) Cameras

func (db *DB) Cameras() ([]*Camera, error)

func (*DB) CloseDb

func (db *DB) CloseDb() error

func (*DB) CreateAlbumStore

func (db *DB) CreateAlbumStore() error

func (*DB) CreateCameraStore

func (db *DB) CreateCameraStore() error

func (*DB) CreateCommentStore

func (db *DB) CreateCommentStore() error

func (*DB) CreateDataStore

func (db *DB) CreateDataStore() error

func (*DB) CreateGuestStore

func (db *DB) CreateGuestStore() error

func (*DB) CreateLikeStore

func (db *DB) CreateLikeStore() error

func (*DB) CreatePhotoStore

func (db *DB) CreatePhotoStore() error

func (*DB) CreateUserStore

func (db *DB) CreateUserStore() error

func (*DB) DeleteAlbum

func (db *DB) DeleteAlbum(id int) error

func (*DB) DeleteAlbumStore

func (db *DB) DeleteAlbumStore() error

func (*DB) DeleteCamera

func (db *DB) DeleteCamera(id string) (bool, error)

func (*DB) DeleteCameraStore

func (db *DB) DeleteCameraStore() error

func (*DB) DeleteCommentStore

func (db *DB) DeleteCommentStore() error

func (*DB) DeleteDataStore

func (db *DB) DeleteDataStore() error

func (*DB) DeleteGuest

func (db *DB) DeleteGuest(uuid uuid.UUID) (bool, error)

func (*DB) DeleteGuestStore

func (db *DB) DeleteGuestStore() error

func (*DB) DeleteLike

func (db *DB) DeleteLike(uuid uuid.UUID, driveId string) error

func (*DB) DeleteLikeStore

func (db *DB) DeleteLikeStore() error

func (*DB) DeleteLikes

func (db *DB) DeleteLikes(uuid uuid.UUID) error

func (*DB) DeletePhoto

func (db *DB) DeletePhoto(id string) (bool, error)

func (*DB) DeletePhotoStore

func (db *DB) DeletePhotoStore() error

func (*DB) DeleteUserStore

func (db *DB) DeleteUserStore() error

func (*DB) Exif

func (db *DB) Exif(id string) (*Exif, error)

func (*DB) Guest

func (db *DB) Guest(uuid uuid.UUID) (*Guest, error)

func (*DB) GuestByEmail

func (db *DB) GuestByEmail(email string) (*Guest, error)

func (*DB) GuestLikes

func (db *DB) GuestLikes(guest uuid.UUID) ([]string, error)

func (*DB) GuestUUID

func (db *DB) GuestUUID(email string) (*uuid.UUID, error)

func (*DB) HasAlbum

func (db *DB) HasAlbum(id int) bool

func (*DB) HasAlbumName

func (db *DB) HasAlbumName(name string) bool

func (*DB) HasCamera

func (db *DB) HasCamera(id string) bool

func (*DB) HasCameraModel

func (db *DB) HasCameraModel(model string) bool

func (*DB) HasGuest

func (db *DB) HasGuest(guest uuid.UUID) bool

func (*DB) HasGuestByEmail

func (db *DB) HasGuestByEmail(email string) bool

func (*DB) HasGuestByName

func (db *DB) HasGuestByName(name string) bool

func (*DB) HasPhoto

func (db *DB) HasPhoto(id string, private bool) bool

func (*DB) Like

func (db *DB) Like(guest uuid.UUID, driveId string) bool

func (*DB) Photo

func (db *DB) Photo(id string, private bool) (*Photo, error)

func (*DB) PhotoAlbums

func (db *DB) PhotoAlbums(photoId string) ([]*Album, error)

func (*DB) PhotoComments

func (db *DB) PhotoComments(driveId string) ([]*Comment, error)

func (*DB) PhotoLikes

func (db *DB) PhotoLikes(driveId string) ([]*Guest, error)

func (*DB) Photos

func (db *DB) Photos(r Range, order PhotoOrder, filter PhotoFilter) ([]*Photo, error)

func (*DB) PopulateFromPhotos

func (db *DB) PopulateFromPhotos() error

func (*DB) SetPrivatePhoto

func (db *DB) SetPrivatePhoto(private bool, id string) (*Photo, error)

func (*DB) UpdateAlbum

func (db *DB) UpdateAlbum(album *Album) (*Album, error)

func (*DB) UpdateCamera

func (db *DB) UpdateCamera(c *Camera) (*Camera, error)

func (*DB) UpdateCameraImage

func (db *DB) UpdateCameraImage(image, id string) (*Camera, error)

func (*DB) UpdateGuest

func (db *DB) UpdateGuest(uuid uuid.UUID, email string, name string) (*Guest, error)

func (*DB) UpdatePhoto

func (db *DB) UpdatePhoto(title string, description string, keywords []string, id string) (*Photo, error)

func (*DB) UpdatePhotoAlbums

func (db *DB) UpdatePhotoAlbums(album []int, photoId string) error

func (*DB) UpdateUser

func (db *DB) UpdateUser(u *User) (*User, error)

Todo: Make this update more clear (i.e. cannot update drive relevant stuff

func (*DB) UpdateUserConfig

func (db *DB) UpdateUserConfig(c string) error

func (*DB) User

func (db *DB) User() (*User, error)

func (*DB) UserConfig

func (db *DB) UserConfig() (string, error)

func (*DB) Verified

func (db *DB) Verified(uuid uuid.UUID) (*Verify, error)

func (*DB) VerifyGuest

func (db *DB) VerifyGuest(uuid uuid.UUID) (*Verify, error)

type DataStore

type DataStore interface {
	PhotoStore
	AlbumStore
	UserStore
	GuestStore
	CommentStore
	LikeStore
	CameraStore
	CreateDataStore() error
	DeleteDataStore() error
	CloseDb() error
}

func NewDB

func NewDB() (DataStore, error)

type Exif

type Exif struct {
	DriveId string
	Data    *mexif.ExifCompact
}

type Guest

type Guest struct {
	Email string `json:"email"`
	Name  string `json:"name"`
}

type GuestStore

type GuestStore interface {
	CreateGuestStore() error
	DeleteGuestStore() error
	AddGuest(id uuid.UUID, u *Guest) error
	DeleteGuest(id uuid.UUID) (bool, error)
	VerifyGuest(id uuid.UUID) (*Verify, error)
	Guest(id uuid.UUID) (*Guest, error)
	GuestByEmail(email string) (*Guest, error)
	GuestUUID(email string) (*uuid.UUID, error)
	HasGuest(id uuid.UUID) bool
	HasGuestByEmail(email string) bool
	HasGuestByName(name string) bool
	Verified(id uuid.UUID) (*Verify, error)
	UpdateGuest(guest uuid.UUID, email string, name string) (*Guest, error)
}

type LikeStore

type LikeStore interface {
	CreateLikeStore() error
	DeleteLikeStore() error
	AddLike(guest uuid.UUID, driveId string) error
	DeleteLike(guest uuid.UUID, driveId string) error
	DeleteLikes(guest uuid.UUID) error
	GuestLikes(guest uuid.UUID) ([]string, error)
	Like(guest uuid.UUID, driveId string) bool
	PhotoLikes(driveId string) ([]*Guest, error)
}

type Photo

type Photo struct {
	DriveId      string    `json:"driveId"`
	Md5          string    `json:"md5"`
	FileName     string    `json:"fileName"`
	Title        string    `json:"title"`
	Keywords     string    `json:"keywords"`
	Description  string    `json:"description"`
	DriveDate    time.Time `json:"driveDate"`
	OriginalDate time.Time `json:"originalDate"`

	CameraMake    string `json:"cameraMake"`
	CameraModel   string `json:"cameraModel"`
	LensMake      string `json:"lensMake,omitempty"`
	LensModel     string `json:"lensModel,omitempty"`
	FocalLength   string `json:"focalLength"`
	FocalLength35 string `json:"focalLength35"`

	Iso      uint    `json:"iso"`
	Exposure string  `json:"exposure"`
	FNumber  float32 `json:"fNumber"`
	Width    uint    `json:"width"`
	Height   uint    `json:"height"`
	Private  bool    `json:"private"`
	Likes    uint    `json:"likes"`
}

type PhotoFilter

type PhotoFilter struct {
	Private     bool
	CameraModel string
}

type PhotoOrder

type PhotoOrder int
const (
	None PhotoOrder = iota
	DriveDate
	OriginalDate
)

type PhotoStore

type PhotoStore interface {
	AddPhoto(p *Photo, exif *mexif.ExifCompact) error
	CreatePhotoStore() error
	DeletePhoto(id string) (bool, error)
	DeletePhotoStore() error
	Exif(id string) (*Exif, error)
	HasPhoto(id string, private bool) bool
	Photo(id string, private bool) (*Photo, error)
	Photos(r Range, order PhotoOrder, filter PhotoFilter) ([]*Photo, error)
	SetPrivatePhoto(private bool, id string) (*Photo, error)
	UpdatePhoto(title string, description string, keywords []string, id string) (*Photo, error)
}

type Range

type Range struct {
	Offset int
	Limit  int
}

type User

type User struct {
	Name            string `json:"name"`
	Bio             string `json:"bio"`
	Pic             string `json:"pic"`
	DriveFolderId   string `json:"driveFolderId,omitempty"`
	DriveFolderName string `json:"driveFolderName,omitempty"`
}

type UserStore

type UserStore interface {
	CreateUserStore() error
	DeleteUserStore() error
	UpdateUser(u *User) (*User, error)
	UpdateUserConfig(c string) error
	User() (*User, error)
	UserConfig() (string, error)
}

type Verify

type Verify struct {
	Verified bool      `json:"verified"`
	Time     time.Time `json:"time"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL