database

package
v0.0.0-...-2686a8b Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyExist = errors.New("already exists")
View Source
var ErrIsExpired = errors.New("already expired")
View Source
var ErrNotExist = errors.New("resource does not exist")

Functions

This section is empty.

Types

type DbConfig

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

func CreateDatabaseConnection

func CreateDatabaseConnection(dbUrl string) (*DbConfig, error)

func (*DbConfig) DeleteSpecificToplistItems

func (dbCfg *DbConfig) DeleteSpecificToplistItems(itemsToDelete []ToplistItem) error

func (*DbConfig) DeleteToplist

func (dbCfg *DbConfig) DeleteToplist(listId int) error

func (*DbConfig) DeleteToplistItems

func (dbCfg *DbConfig) DeleteToplistItems(listId int) error

func (*DbConfig) DeleteUser

func (dbCfg *DbConfig) DeleteUser(userID int) error

func (*DbConfig) GetToplist

func (dbCfg *DbConfig) GetToplist(listId int) (Toplist, error)

func (*DbConfig) GetToplistItems

func (dbCfg *DbConfig) GetToplistItems(listId int) ([]ToplistItem, error)

func (*DbConfig) GetToplistLikes

func (dbCfg *DbConfig) GetToplistLikes(toplistID int) ([]int, error)

func (*DbConfig) GetUserByEmail

func (dbCfg *DbConfig) GetUserByEmail(email string) (User, error)

func (*DbConfig) GetUserByID

func (dbCfg *DbConfig) GetUserByID(userID int) (User, error)

func (*DbConfig) InsertPasswordResetToken

func (dbCfg *DbConfig) InsertPasswordResetToken(user User) error

func (*DbConfig) InsertToplist

func (dbCfg *DbConfig) InsertToplist(toplist Toplist) (Toplist, error)

func (*DbConfig) InsertToplistItems

func (dbCfg *DbConfig) InsertToplistItems(toplistItems []ToplistItem, listId int) ([]ToplistItem, error)

func (*DbConfig) InsertUser

func (dbCfg *DbConfig) InsertUser(user User) (User, error)

func (*DbConfig) IsTokenRevoked

func (dbCfg *DbConfig) IsTokenRevoked(token string) (bool, error)

func (*DbConfig) ListToplists

func (dbCfg *DbConfig) ListToplists(limit, offset int) ([]Toplist, error)

func (*DbConfig) ListToplistsByProperty

func (dbCfg *DbConfig) ListToplistsByProperty(limit int, property string) ([]Toplist, error)

func (*DbConfig) ListToplistsByUser

func (dbCfg *DbConfig) ListToplistsByUser(userID, limit, offset int) ([]Toplist, error)

func (*DbConfig) ResetPassword

func (dbCfg *DbConfig) ResetPassword(newPasswordHash, resetToken string) error

func (*DbConfig) RevokeToken

func (dbCfg *DbConfig) RevokeToken(token string) (Revocation, error)

func (*DbConfig) SearchToplists

func (dbCfg *DbConfig) SearchToplists(searchTerm string, limit, offset int) ([]Toplist, error)

func (*DbConfig) UpdateToplist

func (dbCfg *DbConfig) UpdateToplist(toplist Toplist) (Toplist, error)

func (*DbConfig) UpdateToplistItems

func (dbCfg *DbConfig) UpdateToplistItems(newListItems []ToplistItem, listId int) ([]ToplistItem, error)

func (*DbConfig) UpdateToplistLikes

func (dbCfg *DbConfig) UpdateToplistLikes(toplistID, userID int) error

func (*DbConfig) UpdateToplistViews

func (dbCfg *DbConfig) UpdateToplistViews(toplistID int) (Toplist, error)

func (*DbConfig) UpdateUserEmail

func (dbCfg *DbConfig) UpdateUserEmail(userID int, email string) (User, error)

func (*DbConfig) UpdateUserPassword

func (dbCfg *DbConfig) UpdateUserPassword(userID int, hashedPassword string) (User, error)

func (*DbConfig) UpdateUserUsername

func (dbCfg *DbConfig) UpdateUserUsername(userID int, username string) (User, error)

func (*DbConfig) UserWithEmailExists

func (dbCfg *DbConfig) UserWithEmailExists(email string) (bool, error)

func (*DbConfig) UserWithUsernameExists

func (dbCfg *DbConfig) UserWithUsernameExists(username string) (bool, error)

type Revocation

type Revocation struct {
	Token     string    `json:"token"`
	RevokedAt time.Time `json:"revoked_at"`
}

type Toplist

type Toplist struct {
	ToplistID   int           `json:"toplist_id"`
	Title       string        `json:"title"`
	Description string        `json:"description"`
	UserID      int           `json:"user_id"`
	Username    string        `json:"username"`
	CreatedAt   time.Time     `json:"created_at"`
	Items       []ToplistItem `json:"items"`
	Views       int           `json:"views"`
	LikeCount   int           `json:"like_count"`
	LikeIDs     []int         `json:"like_ids"`
}

type ToplistItem

type ToplistItem struct {
	ItemID      int    `json:"item_id"`
	ListID      int    `json:"list_id"`
	Rank        int    `json:"rank"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Image       []byte `json:"-"`
	ImagePath   string `json:"image_path"`
}

type User

type User struct {
	ID                         int       `json:"id"`
	Email                      string    `json:"email"`
	HashedPassword             string    `json:"hashed_password"`
	CreatedAt                  time.Time `json:"created_at"`
	PasswordResetToken         string    `json:"password_reset_token"`
	PasswordResetTokenExpireAt time.Time `json:"password_reset_token_expire_at"`
	Username                   string    `json:"username"`
}

Jump to

Keyboard shortcuts

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