database

package
v0.0.0-...-f767ba8 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	Type    string
	ConnStr string
	SQL     *sql.DB
}

func Open

func Open(databaseType string, databaseConnStr string, appVersion *version.Version) (*Database, error)

func (*Database) Close

func (db *Database) Close() error

func (*Database) CreateUser

func (db *Database) CreateUser(newUser *NewUser) error

CreareUser reates a new user in the 'users' table. A non-nil error is returned if query execution fails.

func (*Database) DeleteUser

func (db *Database) DeleteUser(username string) error

DeleteUser removes a user from the 'users' table based on its username. A non-nil error is returned if the query cannot be executed or no user is found.

func (*Database) GetStat

func (db *Database) GetStat() (*Stat, error)

func (*Database) GetUser

func (db *Database) GetUser(username string) (*User, error)

GetUser reads the 'users' table and returns the user with the specified username. A non-nil error is returned if the query cannot be executed or if no user is found.

func (*Database) UserCount

func (db *Database) UserCount() (uint64, error)

UserCount returns the number of users in the 'users' table. A non-nil error is returned if the query cannot be executed.

func (*Database) UserExists

func (db *Database) UserExists(username string) (bool, error)

UserExists returns true if the 'users' table contains a row with the specified username, and false otherwise. A non-nil error is returned if the query cannot be executed.

type NewUser

type NewUser struct {
	Username string `db:"username"`
	Salt     []byte `db:"salt"`
	Verifier []byte `db:"verifier"`
}

type Stat

type Stat struct {
	ID      uint64           `db:"id"`
	Version *version.Version `db:"version"`
}

type User

type User struct {
	ID       uint64 `db:"id"`
	Username string `db:"username"`
	Salt     []byte `db:"salt"`
	Verifier []byte `db:"verifier"`
}

Jump to

Keyboard shortcuts

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