models

package
v0.0.0-...-8833268 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const MsgError = "An error occurred."

Variables

View Source
var (
	ErrNoRecord = errors.New("models: no matching record found")

	ErrInvalidCredentials = errors.New("models: invalid credentials")

	ErrDuplicateUsername = errors.New("models: duplicate username")
)

Functions

This section is empty.

Types

type Response

type Response struct {
	Success   bool
	Message   string
	Timestamp time.Time
	Command   string
	Args      []string
}

func NewResponse

func NewResponse(cmd string, arg []string) Response

func (*Response) Error

func (r *Response) Error()

func (*Response) Succeed

func (r *Response) Succeed(msg string)

type User

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

type UserModel

type UserModel struct {
	DB *sql.DB
}

func (*UserModel) Authenticate

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

func (*UserModel) Exists

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

func (*UserModel) Insert

func (m *UserModel) Insert(username, password string) error

type UserModelInterface

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

Jump to

Keyboard shortcuts

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