database

package
v0.0.0-...-fd5a099 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBWrapper

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

This wrapper exists solely so that member functions can be written to work on the database.

func GetDB

func GetDB() (*DBWrapper, error)

The singleton pattern for a database connection.

func (*DBWrapper) AddCredentialToUser

func (db *DBWrapper) AddCredentialToUser(username string, cred models.Credential) error

Adds the given credential to the user with the given username

func (*DBWrapper) AddUser

func (db *DBWrapper) AddUser(user models.User) error

Adds User to database

func (*DBWrapper) DeleteUserByID

func (db *DBWrapper) DeleteUserByID(id uint) error

Deletes the user with the given ID

func (*DBWrapper) DeleteUserByUsername

func (db *DBWrapper) DeleteUserByUsername(username string) error

Deletes user with the given username

func (*DBWrapper) GetUserByID

func (db *DBWrapper) GetUserByID(id uint) (models.User, error)

Gets the user object based on the given ID

func (*DBWrapper) GetUserByUsername

func (db *DBWrapper) GetUserByUsername(username string) (models.User, error)

Gets the user object based on the given username

func (*DBWrapper) UpdateUser

func (db *DBWrapper) UpdateUser(username string, userUpdates models.User) error

Updates the given user to the values given in the object

Jump to

Keyboard shortcuts

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