users

package
v0.0.0-...-25c177e Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPasswordRequired = errors.New("password can't be blank")
	ErrPasswordLen      = errors.New("password must have at least 6 characters")
	ErrNameRequired     = errors.New("Name is required")
	ErrLoginRequired    = errors.New("Login is required")
)

Functions

func Delete

func Delete(db *sql.DB, id int64) error

func Insert

func Insert(db *sql.DB, u *User) (int64, error)

func SetRoutes

func SetRoutes(r chi.Router, db *sql.DB)

func Update

func Update(db *sql.DB, user *User, id int64) error

Types

type User

type User struct {
	ID         int64     `json:"id"`
	Name       string    `json:"name"`
	Login      string    `json:"login"`
	Password   string    `json:"password`
	CreatedAt  time.Time `json:"create_at"`
	ModifiedAt time.Time `json:"modified_at"`
	Deleted    bool      `json:"-"`
	LastLogin  time.Time `json:"last_login"`
}

func New

func New(name, login, password string) (*User, error)

func Select

func Select(db *sql.DB, id int64) (*User, error)

func SelectAll

func SelectAll(db *sql.DB) ([]User, error)

func (*User) SetPassword

func (u *User) SetPassword(password string) error

func (*User) Validate

func (u *User) Validate() error

Jump to

Keyboard shortcuts

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