models

package
v0.0.0-...-37dc637 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicateBackHalf = errors.New("models: duplicate back-half")
View Source
var ErrDuplicateEmail = errors.New("models: duplicate email")
View Source
var ErrInvalidCredentials = errors.New("models: invalid credentials")
View Source
var ErrNoRecord = errors.New("models: no matching record found")

Functions

This section is empty.

Types

type Link struct {
	ID          uuid.UUID
	URL         string
	BackHalf    string
	Engagements int64
	UserID      sql.Null[uuid.UUID]
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

type LinkModel

type LinkModel struct {
	DB *sql.DB
}

func (*LinkModel) BackHalfExists

func (m *LinkModel) BackHalfExists(backHalf string) (bool, error)

func (*LinkModel) Delete

func (m *LinkModel) Delete(id string) error

func (*LinkModel) GetByBackHalf

func (m *LinkModel) GetByBackHalf(backHalf string) (*Link, error)

func (*LinkModel) GetByID

func (m *LinkModel) GetByID(id string) (*Link, error)

func (*LinkModel) GetByUserID

func (m *LinkModel) GetByUserID(userID string) ([]*Link, error)

func (*LinkModel) GetSummaryByUserID

func (m *LinkModel) GetSummaryByUserID(userID string) (*Summary, error)

func (*LinkModel) Insert

func (m *LinkModel) Insert(url, backHalf string, userID string) (*Link, error)

func (*LinkModel) Update

func (m *LinkModel) Update(id, url, backHalf string) error

func (*LinkModel) UpdateEngagements

func (m *LinkModel) UpdateEngagements(id string, engagements int) error

type Summary

type Summary struct {
	TotalLinks       int64
	TotalEngagements int64
}

type User

type User struct {
	ID         uuid.UUID
	Email      string
	Password   []byte
	DateJoined time.Time
}

type UserModel

type UserModel struct {
	DB *sql.DB
}

func (*UserModel) Authenticate

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

func (*UserModel) Exists

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

func (*UserModel) Insert

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

Jump to

Keyboard shortcuts

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