database

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *sql.DB
View Source
var (
	ErrWrongNumberOfAffectedRows = errors.New("wrong number of affected rows")
)

Functions

func ApplyMigrations added in v1.3.0

func ApplyMigrations() error

func CountAdmins

func CountAdmins() (int64, error)

func CreateGroup added in v1.3.0

func CreateGroup(group *Group) error

Create a new group in the database. The function fills in the ID.

func CreateLink(link *Link) error

Create a new link in the database. The function fills in the ID.

func DeleteAdmin added in v1.3.0

func DeleteAdmin(id int) error

func DeleteGroup added in v1.3.0

func DeleteGroup(groupID int) error
func DeleteLink(linkID int) error

func EstablishDatabaseConnection added in v1.3.0

func EstablishDatabaseConnection(cfg *config.Config) error

func UpdateGroup added in v1.3.0

func UpdateGroup(id int, name string) error
func UpdateLink(link *Link) error

Types

type Admin

type Admin struct {
	ID       int
	Username string
	Bcrypt   string
}

func CreateAdmin

func CreateAdmin(username string, password string) (*Admin, error)

func GetAdminIfPasswordMatches added in v1.3.0

func GetAdminIfPasswordMatches(username string, password string) (*Admin, error)

type Group

type Group struct {
	ID    int    `json:"id"`
	Name  string `json:"name"`
	Links []Link `json:"links"`
}
func GetGroupsWithLinks() ([]Group, error)
type Link struct {
	ID      int     `json:"id"`
	Name    string  `json:"name"`
	Href    string  `json:"href"`
	GroupID int     `json:"-"`
	Icon    *string `json:"icon,omitempty"`
}
func GetLink(id int) (*Link, error)

func GetLinksFromGroup added in v1.3.0

func GetLinksFromGroup(groupID int) ([]Link, error)

Jump to

Keyboard shortcuts

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