Documentation ¶
Index ¶
- Constants
- Variables
- type Business
- func (b *Business) Count(ctx context.Context, filter QueryFilter) (int, error)
- func (b *Business) Create(ctx context.Context, nu NewUser) (User, error)
- func (b *Business) Delete(ctx context.Context, usr User) error
- func (b *Business) Query(ctx context.Context, filter QueryFilter, orderBy order.By, pageNumber int, ...) ([]User, error)
- func (b *Business) QueryByEmail(ctx context.Context, email mail.Address) (User, error)
- func (b *Business) QueryByID(ctx context.Context, userID uuid.UUID) (User, error)
- func (b *Business) Update(ctx context.Context, usr User, uu UpdateUser) (User, error)
- type Name
- type NewUser
- type QueryFilter
- type Role
- type Storer
- type UpdateUser
- type User
Constants ¶
const ( OrderByID = "user_id" OrderByName = "name" OrderByEmail = "email" OrderByRoles = "roles" OrderByEnabled = "enabled" )
Set of fields that the results can be ordered by.
Variables ¶
var ( ErrNotFound = errors.New("user not found") ErrUniqueEmail = errors.New("email is not unique") ErrAuthenticationFailure = errors.New("authentication failed") )
Set of error variables for CRUD operations.
DefaultOrderBy represents the default way we sort.
var Names nameSet
var Roles = roleSet{
Admin: newRole("ADMIN"),
User: newRole("USER"),
}
Roles represents the set of roles that can be used.
Functions ¶
This section is empty.
Types ¶
type Business ¶
type Business struct {
// contains filtered or unexported fields
}
Business manages the set of APIs for user access.
func NewBusiness ¶
NewBusiness constructs a user business API for use.
func (*Business) Query ¶
func (b *Business) Query(ctx context.Context, filter QueryFilter, orderBy order.By, pageNumber int, rowsPerPage int) ([]User, error)
Query retrieves a list of existing users.
func (*Business) QueryByEmail ¶
QueryByEmail finds the user by a specified user email.
type Name ¶
type Name struct {
// contains filtered or unexported fields
}
Name represents a name in the system.
func (Name) MarshalText ¶
MarshalText implement the marshal interface for JSON conversions.
func (*Name) UnmarshalText ¶
UnmarshalText implement the unmarshal interface for JSON conversions.
type NewUser ¶
NewUser contains information needed to create a new user.
func TestNewUsers ¶
TestNewUsers is a helper method for testing.
type QueryFilter ¶
type QueryFilter struct { ID *uuid.UUID Name *Name Email *mail.Address StartCreatedDate *time.Time EndCreatedDate *time.Time }
QueryFilter holds the available fields a query can be filtered on. We are using pointer semantics because the With API mutates the value.
type Role ¶
type Role struct {
// contains filtered or unexported fields
}
Role represents a role in the system.
func (Role) MarshalText ¶
MarshalText implement the marshal interface for JSON conversions.
func (*Role) UnmarshalText ¶
UnmarshalText implement the unmarshal interface for JSON conversions.
type Storer ¶
type Storer interface { Create(ctx context.Context, usr User) error Update(ctx context.Context, usr User) error Delete(ctx context.Context, usr User) error Query(ctx context.Context, filter QueryFilter, orderBy order.By, pageNumber int, rowsPerPage int) ([]User, error) Count(ctx context.Context, filter QueryFilter) (int, error) QueryByID(ctx context.Context, userID uuid.UUID) (User, error) QueryByEmail(ctx context.Context, email mail.Address) (User, error) }
Storer interface declares the behavior this package needs to perists and retrieve data.
type UpdateUser ¶
type UpdateUser struct { Name *Name Email *mail.Address Roles []Role Guild *string Password *string Enabled *bool }
UpdateUser contains information needed to update a user.