models

package
v0.0.0-...-d5b6c7e Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoRecord              = errors.New("models: no matching record found")
	ErrInvalidCredentials    = errors.New("models: invalid credentials")
	ErrDuplicateEmail        = errors.New("models: duplicate email")
	ErrDuplicateNotification = errors.New("models: duplicate notification")
	ErrDuplicateClass        = errors.New("models: duplicate class")
)

Functions

This section is empty.

Types

type Class

type Class struct {
	ClassID   int
	Name      string
	Link      string
	Professor string
}

type ClassModel

type ClassModel struct {
	DB *sql.DB
}

func (*ClassModel) Classlist

func (m *ClassModel) Classlist() ([]Class, error)

func (*ClassModel) Get

func (m *ClassModel) Get(id int) (Class, error)

func (*ClassModel) Insert

func (m *ClassModel) Insert(classid int, name string, link string, professor string) (int, error)

type ClassModelInterface

type ClassModelInterface interface {
	Insert(classid int, name string, link string, professor string) (int, error)
	Get(id int) (Class, error)
	Classlist() ([]Class, error)
}

type Notification

type Notification struct {
	NotificationID int
	Name           string
	Link           string
}

type NotificationModel

type NotificationModel struct {
	DB *sql.DB
}

func (*NotificationModel) Delete

func (n *NotificationModel) Delete(notificationid int) error

func (*NotificationModel) Insert

func (n *NotificationModel) Insert(email string, classid int, expires int) error

func (*NotificationModel) NotificationList

func (n *NotificationModel) NotificationList(email string) ([]Notification, error)

type NotificationModelInterface

type NotificationModelInterface interface {
	Insert(email string, classid int, expires int) error
	Delete(notification int) error
	NotificationList(email string) ([]Notification, error)
}

type User

type User struct {
	ID             int
	Name           string
	Email          string
	HashedPassword []byte
	Created        time.Time
}

type UserModel

type UserModel struct {
	DB *sql.DB
}

func (*UserModel) Authenticate

func (m *UserModel) Authenticate(email, password string) (int, error)

authenticate the user and make sure credentials match using bcrypt

func (*UserModel) Exists

func (m *UserModel) Exists(userid int) (bool, error)

func (*UserModel) Insert

func (m *UserModel) Insert(name, email, password string) error

type UserModelInterface

type UserModelInterface interface {
	Insert(name, email, password string) error
	Authenticate(email, password string) (int, error)
	Exists(id int) (bool, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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