Documentation ¶
Index ¶
- type DB
- func (db DB) AddGalleryItem(item entities.GalleryItem) error
- func (db DB) AddPhotos(files []string) error
- func (db DB) AddProjectImages(galleryID string, files []string) error
- func (db DB) AddSession(session *entities.Session) error
- func (db DB) AddUser(username, password string, protected bool) error
- func (db DB) ChangeProjectThumbnail(name, newThumb string) error
- func (db DB) Close()
- func (db DB) GetGalleryItems() ([]*entities.GalleryItem, error)
- func (db DB) GetLogin(username, password string) (*entities.User, error)
- func (db DB) GetPhotos() ([]*entities.Photo, error)
- func (db DB) GetProject(name string) (*entities.GalleryItem, error)
- func (db DB) GetSession(token string) (*entities.Session, error)
- func (db DB) GetUser(id string) (*entities.User, error)
- func (db DB) GetUsers() ([]*entities.User, error)
- func (db DB) RemoveGalleryItem(name string) error
- func (db DB) RemovePhotos(files []string) error
- func (db DB) RemoveProjectImages(galleryID string, files []string) error
- func (db DB) RemoveSession(token string) error
- func (db DB) RemoveUser(id string) error
- func (db DB) UpdateLoginTime(id uint) error
- func (db DB) UpdateProject(project *entities.GalleryItem) error
- func (db DB) UpdateSession(session *entities.Session) error
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 (DB) AddGalleryItem ¶
func (db DB) AddGalleryItem(item entities.GalleryItem) error
AddGalleryItem adds a new gallery item to the database.
func (DB) AddProjectImages ¶
AddProjectImages inserts new image names for a project into the database.
func (DB) AddSession ¶
AddSession saves a login session in the database.
func (DB) ChangeProjectThumbnail ¶
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 ¶
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) GetProject ¶
func (db DB) GetProject(name string) (*entities.GalleryItem, error)
GetProject retrieves a project from the database with the given name.
func (DB) GetSession ¶
GetSession fetches a session from the database.
func (DB) RemoveGalleryItem ¶
RemoveGalleryItem delets a gallery item from the database.
func (DB) RemovePhotos ¶
RemovePhotos removes photos in the list of files from the database.
func (DB) RemoveProjectImages ¶
RemoveProjectImages deletes project images from the database.
func (DB) RemoveSession ¶
RemoveSession deletes a session from the database by the session token.
func (DB) RemoveUser ¶
RemoveUser deletes a user from the database.
func (DB) UpdateLoginTime ¶
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.