users

package
v0.0.0-...-4269795 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFetchingUser   = errors.New("could not fetch User by email")
	ErrUpdatingUser   = errors.New("could not update User ")
	ErrNoUserFound    = errors.New("no User  found")
	ErrDeletingUser   = errors.New("could not delete User ")
	ErrNotImplemented = errors.New("not implemented")
)

Functions

This section is empty.

Types

type Service

type Service struct {
	Store UserStore
}

func NewService

func NewService(store UserStore) *Service

func (*Service) CreateUser

func (s *Service) CreateUser(ctx context.Context, in User) (User, error)

CreateUser - adds a new user to the database

func (*Service) DeleteUser

func (s *Service) DeleteUser(ctx context.Context, email string) error

DeleteUser - deletes a user from the database by email

func (*Service) GetUser

func (s *Service) GetUser(ctx context.Context, email string) (User, error)

GetUser - retrieves user data by their email from the database

func (*Service) UpdateUser

func (s *Service) UpdateUser(
	ctx context.Context, in User,
) (User, error)

UpdateUser - updates a user data with new user info

type User

type User struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

User - defines our user structure

type UserStore

type UserStore interface {
	GetUser(ctx context.Context, email string) (User, error)
	CreateUser(ctx context.Context, in User) (User, error)
	UpdateUser(ctx context.Context, in User) (User, error)
	DeleteUser(ctx context.Context, email string) error
}

UserStore - defines the interface we need our user storage layer to implement

Jump to

Keyboard shortcuts

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