models

package
v0.0.0-...-6660091 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2019 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDB

func GetDB() *gorm.DB

GetDB returns a handle to database object.

func GetHTMLTemplates

func GetHTMLTemplates() *template.Template

GetHTMLTemplates returns a handle to the HTML Templates.

func GetRandomPicture

func GetRandomPicture() image.Image

GetRandomPicture will return a random picture from database.

func GetRandomPictureInfo

func GetRandomPictureInfo() image.Image

GetRandomPictureInfo will return a random picture from database.

Types

type Picture

type Picture struct {
	gorm.Model
	Path        string
	Description string
}

Picture is the core entity of this program. Any image is defined as a 'picture'.

func GetPictureByID

func GetPictureByID(id uint) *Picture

GetPictureByID will return the entry determined by ID given.

func GetRecentPics

func GetRecentPics(n uint) []Picture

GetRecentPics will return a list of n recently added pictures.

func (*Picture) Create

func (pic *Picture) Create() map[string]interface{}

Create saves the new picture in database.

func (*Picture) Validate

func (pic *Picture) Validate() (map[string]interface{}, bool)

Validate checks if the Picture entity has valid data, before saving. If field ID is defined (higher than 0), it will check if it exists in the database.

Notes

Bugs

  • : The first query should get only the IDs; we do not need the entire rows.

Jump to

Keyboard shortcuts

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