database

package
v0.0.0-...-e5939f5 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrQRCodeNotFound = &QRCodeNotFoundError{}
View Source
var ErrUserNotFound = &UserNotFoundError{}

Functions

This section is empty.

Types

type DB

type DB struct {
	*sqlx.DB
}

func New

func New(dsn string, automigrate bool) (*DB, error)

func (*DB) CreateQRCode

func (db *DB) CreateQRCode(userID int, data, imagePath string) (int, error)

func (*DB) DeleteQRCode

func (db *DB) DeleteQRCode(qrcodeID int) error

func (*DB) GetAllQRCodesByUserID

func (db *DB) GetAllQRCodesByUserID(userID int) ([]QRCode, error)

func (*DB) GetQRCodeByID

func (db *DB) GetQRCodeByID(qrcodeID int) (*QRCode, error)

func (*DB) GetUser

func (db *DB) GetUser(usernameOrEmail string) (*User, error)

func (*DB) NewUser

func (db *DB) NewUser(username string, password_hash string, email string) error

func (*DB) UpdateQRCode

func (db *DB) UpdateQRCode(qrcodeID int, data, imagePath string) error

type QRCode

type QRCode struct {
	QrcodeID  int       `db:"qrcode_id"`
	UserID    int       `db:"user_id"`
	Data      string    `db:"data"`
	ImagePath string    `db:"image_path"`
	CreatedAt time.Time `db:"created_at"`
}

type QRCodeNotFoundError

type QRCodeNotFoundError struct {
	ID int
}

represents an error when a QR code is not found

func (*QRCodeNotFoundError) Error

func (e *QRCodeNotFoundError) Error() string

type User

type User struct {
	ID            int     `db:"id"`
	Username      string  `db:"username"`
	Password_hash string  `db:"password_hash"`
	Email         *string `db:"email"`
}

type UserNotFoundError

type UserNotFoundError struct {
	UsernameOrEmail string
}

UserNotFoundError represents an error when a user is not found.

func (*UserNotFoundError) Error

func (e *UserNotFoundError) Error() string

Error returns the error message.

Jump to

Keyboard shortcuts

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