database

package
v0.0.0-...-95711e6 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB holds our database connection.

func Connect

func Connect(username, password, database string) (*DB, error)

Connect opens a connection to the database and creates the table structure.

func (DB) AddGalleryItem

func (db DB) AddGalleryItem(item entities.GalleryItem) error

AddGalleryItem adds a new gallery item to the database.

func (DB) AddPhotos

func (db DB) AddPhotos(files []string) error

AddPhotos inserts new photo image names into the database.

func (DB) AddProjectImages

func (db DB) AddProjectImages(galleryID string, files []string) error

AddProjectImages inserts new image names for a project into the database.

func (DB) AddSession

func (db DB) AddSession(session *entities.Session) error

AddSession saves a login session in the database.

func (DB) AddUser

func (db DB) AddUser(username, password string, protected bool) error

AddUser inserts a new user into the database.

func (DB) ChangeProjectThumbnail

func (db DB) ChangeProjectThumbnail(name, newThumb string) error

ChangeProjectThumbnail sets a new thumbnail for a project.

func (DB) Close

func (db DB) Close()

Close closes the database connection and waits for all current queries to finish.

func (DB) GetGalleryItems

func (db DB) GetGalleryItems() ([]*entities.GalleryItem, error)

GetGalleryItems returns all gallery items from the database.

func (DB) GetLogin

func (db DB) GetLogin(username, password string) (*entities.User, error)

GetLogin looks for a matching user for the given username and password. If a match is found, a User struct is returned with the id and username.

func (DB) GetPhotos

func (db DB) GetPhotos() ([]*entities.Photo, error)

GetPhotos fetches all photos from the database.

func (DB) GetProject

func (db DB) GetProject(name string) (*entities.GalleryItem, error)

GetProject retrieves a project from the database with the given name.

func (DB) GetSession

func (db DB) GetSession(token string) (*entities.Session, error)

GetSession fetches a session from the database.

func (DB) GetUser

func (db DB) GetUser(id string) (*entities.User, error)

GetUser fetches a single user from the database with the given ID.

func (DB) GetUsers

func (db DB) GetUsers() ([]*entities.User, error)

GetUsers fetches all of the users from the database.

func (DB) RemoveGalleryItem

func (db DB) RemoveGalleryItem(name string) error

RemoveGalleryItem delets a gallery item from the database.

func (DB) RemovePhotos

func (db DB) RemovePhotos(files []string) error

RemovePhotos removes photos in the list of files from the database.

func (DB) RemoveProjectImages

func (db DB) RemoveProjectImages(galleryID string, files []string) error

RemoveProjectImages deletes project images from the database.

func (DB) RemoveSession

func (db DB) RemoveSession(token string) error

RemoveSession deletes a session from the database by the session token.

func (DB) RemoveUser

func (db DB) RemoveUser(id string) error

RemoveUser deletes a user from the database.

func (DB) UpdateLoginTime

func (db DB) UpdateLoginTime(id uint) error

UpdateLoginTime sets a user's last login time to `time.Now()`.

func (DB) UpdateProject

func (db DB) UpdateProject(project *entities.GalleryItem) error

UpdateProject sets the title, caption, project info, and embed URL fields for a project with the same name in the database.

func (DB) UpdateSession

func (db DB) UpdateSession(session *entities.Session) error

UpdateSession sets a new expiration time for an existing session.

Jump to

Keyboard shortcuts

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