models

package
v0.0.0-...-522d2e6 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UniqueConstraintViolation = "23505"
)

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 Snippet

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

type SnippetModel

type SnippetModel struct {
	DB *pgxpool.Pool
}

func (*SnippetModel) Get

func (m *SnippetModel) Get(id int) (*Snippet, error)

func (*SnippetModel) Insert

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

func (*SnippetModel) Latest

func (m *SnippetModel) Latest() ([]*Snippet, error)

type SnippetModelInterface

type SnippetModelInterface interface {
	Insert(title string, content string, expires int) (int, error)
	Get(id int) (*Snippet, error)
	Latest() ([]*Snippet, error)
}

type User

type User struct {
	ID             int
	Name           string
	Email          string
	HashedPassword []byte `json:"-"`
	Created        time.Time
}

type UserModel

type UserModel struct {
	DB *pgxpool.Pool
}

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

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

func (*UserModel) PasswordUpdate

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

type UserModelInterface

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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