user

package
v0.0.0-...-eccf771 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicate    = errors.New("record already exists")
	ErrNotExists    = errors.New("row not exists")
	ErrUpdateFailed = errors.New("update failed")
	ErrDeleteFailed = errors.New("delete failed")
)

Functions

This section is empty.

Types

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

func NewUserRepository

func NewUserRepository(db *sql.DB) *Repository

func (*Repository) All

func (r *Repository) All() ([]User, error)

func (*Repository) Create

func (r *Repository) Create(user *User, passwd string) (*User, error)

func (*Repository) Delete

func (r *Repository) Delete(id int64) error

func (*Repository) GetByEmail

func (r *Repository) GetByEmail(email string) (*User, error)

func (*Repository) GetByID

func (r *Repository) GetByID(id int64) (*User, error)

func (*Repository) Migrate

func (r *Repository) Migrate() error

FIXME: Using serial number as an id can leak information about the user. Don't do this in production.

func (*Repository) Update

func (r *Repository) Update(id int64, updated User) (*User, error)

type User

type User struct {
	ID           int64  `json:"id,omitempty"`
	Email        string `json:"email,omitempty"`
	Name         string `json:"name,omitempty"`
	Location     string `json:"location,omitempty"`
	About        string `json:"about,omitempty"`
	PasswordHash string `json:"-"`
}

Jump to

Keyboard shortcuts

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