user

package
Version: v0.0.0-...-b472bfd Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package user provides support for managing users in the database.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotExists = errors.New("user does not exist")
	ErrExists    = errors.New("user exists")
	ErrNotFound  = errors.New("user not found")
)

Set of error variables for CRUD operations.

Functions

This section is empty.

Types

type NewUser

type NewUser struct {
	Name            string `json:"name"`
	Email           string `json:"email"`
	Role            string `json:"role"`
	Password        string `json:"password"`
	PasswordConfirm string `json:"password_confirm"`
}

NewUser contains information needed to create a new User.

type Store

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

Store manages the set of API's for user access.

func NewStore

func NewStore(log *log.Logger, gql *graphql.GraphQL) Store

NewStore constructs a user store for api access.

func (Store) Add

func (s Store) Add(ctx context.Context, traceID string, nu NewUser, now time.Time) (User, error)

Add adds a new user to the database. If the user already exists this function will fail but the found user is returned. If the user is being added, the user with the id from the database is returned.

func (Store) Delete

func (s Store) Delete(ctx context.Context, traceID string, userID string) error

Delete removes a user from the database by its ID. If the user doesn't already exist, this function will fail.

func (Store) QueryByEmail

func (s Store) QueryByEmail(ctx context.Context, traceID string, email string) (User, error)

QueryByEmail returns the specified user from the database by email.

func (Store) QueryByID

func (s Store) QueryByID(ctx context.Context, traceID string, userID string) (User, error)

QueryByID returns the specified user from the database by the city id.

func (Store) Update

func (s Store) Update(ctx context.Context, traceID string, usr User) error

Update updates a user in the database by its ID. If the user doesn't already exist, this function will fail.

type User

type User struct {
	ID           string    `json:"id"`
	Name         string    `json:"name"`
	Email        string    `json:"email"`
	Role         string    `json:"role"`
	PasswordHash string    `json:"password_hash"`
	DateCreated  time.Time `json:"date_created"`
	DateUpdated  time.Time `json:"date_updated"`
}

User represents someone with access to the system.

Source Files

Jump to

Keyboard shortcuts

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