models

package
v0.0.0-...-fae24e2 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 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")

	ErrUserNotExist = errors.New("models: user not found")
)

Functions

This section is empty.

Types

type Quint

type Quint struct {
	ID      int
	Title   string
	Content string
	Created time.Time
	Expires time.Time
}

type QuintModel

type QuintModel struct {
	DB *sql.DB
}

func (*QuintModel) Get

func (m *QuintModel) Get(id int) (*Quint, error)

func (*QuintModel) Insert

func (m *QuintModel) Insert(title string, content string, expires int) (int, error)

func (*QuintModel) Latest

func (m *QuintModel) Latest() ([]*Quint, 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)

func (*UserModel) Exists

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

func (*UserModel) Get

func (m *UserModel) Get(id int) (*User, error)

func (*UserModel) GetName

func (m *UserModel) GetName(id int) (string, error)

func (*UserModel) Insert

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

func (*UserModel) PasswordUpdate

func (m *UserModel) PasswordUpdate(id int, currentPassword, newPassword string) error

type UserModelInterface

type UserModelInterface interface {
	Insert(name, email, password string) error
	Authenticate(email, password string) (int, error)
	Exists(id int) (bool, error)
	Get(id int) (*User, error)
	GetName(id int) (string, error)
	PasswordUpdate(id int, currentPassword, newPassword string) error
}

Jump to

Keyboard shortcuts

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