Documentation ¶
Overview ¶
Package user provides support for managing users in the database.
Index ¶
- Variables
- type NewUser
- type Store
- func (s Store) Add(ctx context.Context, traceID string, nu NewUser, now time.Time) (User, error)
- func (s Store) Delete(ctx context.Context, traceID string, userID string) error
- func (s Store) QueryByEmail(ctx context.Context, traceID string, email string) (User, error)
- func (s Store) QueryByID(ctx context.Context, traceID string, userID string) (User, error)
- func (s Store) Update(ctx context.Context, traceID string, usr User) error
- type User
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 (Store) Add ¶
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 ¶
Delete removes a user from the database by its ID. If the user doesn't already exist, this function will fail.
func (Store) QueryByEmail ¶
QueryByEmail returns the specified user from the database by email.
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.
Click to show internal directories.
Click to hide internal directories.