models

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT 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")
)

Functions

This section is empty.

Types

type BlogPost

type BlogPost struct {
	ID      int
	Title   string
	Content string
	Created time.Time
	Author  string
	ImgURL  string
	Version int
}

type BlogPostModel

type BlogPostModel struct {
	DB *sql.DB
}

func (*BlogPostModel) All

func (m *BlogPostModel) All() ([]*BlogPost, error)

func (*BlogPostModel) Get

func (m *BlogPostModel) Get(id int) (*BlogPost, error)

func (*BlogPostModel) Insert

func (m *BlogPostModel) Insert(title string, content string, author string, imgURL string) (int, error)

func (*BlogPostModel) Latest

func (m *BlogPostModel) Latest() ([]*BlogPost, error)

type BlogPostModelInterface

type BlogPostModelInterface interface {
	Insert(title string, content string, author string, imgURL string) (int, error)
	Get(id int) (*BlogPost, error)
	Latest() ([]*BlogPost, error)
	All() ([]*BlogPost, error)
}

type MailData added in v0.2.0

type MailData struct {
	Name    string
	From    string
	Subject string
	Content string
	To      string
}

MailData holds email

type MailServer added in v0.2.0

type MailServer struct {
	Host     string
	Port     int
	Username string
	Password string
}

MailServer holds mail server parameters

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) 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