users

package
v0.0.0-...-6343e97 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrInvalidFilterValue is returned when a filter value is empty.
	ErrInvalidFilterValue = errors.Error("invalid_filter_value: invalid filter value")
	// ErrInvalidFilterMatchType is returned when a filter match type is not found in the supported enum list.
	ErrInvalidFilterMatchType = errors.Error("invalid_filter_match_type: invalid filter match type")
	// ErrInvalidFilterField is returned when a filter field is not found in the supported enum list.
	ErrInvalidFilterField = errors.Error("invalid_filter_field: invalid filter field")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Events

type Events interface {
	Produce(ctx context.Context, topic events.Topic, payload interface{})
}

Events represents a type for producing events on user CRUD operations.

type Store

type Store interface {
	InsertUser(ctx context.Context, user *model.User) (*model.User, error)
	UpdateUser(ctx context.Context, user *model.User) (*model.User, error)
	GetUser(ctx context.Context, id string) (*model.User, error)
	GetUserByEmail(ctx context.Context, email string) (*model.User, error)
	FindUsers(ctx context.Context, filters []model.Filter, offset, limit int64) ([]*model.User, error)
	DeleteUser(ctx context.Context, id string) error
}

Store represents a type for storing a user in a database.

type Users

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

Users provides functionality for CRUD operations on a user.

func New

func New(s Store, e Events) *Users

New will instantiate a new instance of Users.

func (*Users) CreateUser

func (u *Users) CreateUser(ctx context.Context, user *model.User) (*model.User, error)

CreateUser will try to create a user in our database with the provided data if it represents a unique new user.

func (*Users) DeleteUser

func (u *Users) DeleteUser(ctx context.Context, id string) error

DeleteUser will try to delete an existing user in our database with the provided id.

func (*Users) FindUsers

func (u *Users) FindUsers(ctx context.Context, filters []model.Filter, offset, limit int64) ([]*model.User, error)

FindUsers will retrieve a list of users based on matching all of the the provided filters and using pagination if limit is gt 0.

func (*Users) GetUser

func (u *Users) GetUser(ctx context.Context, id string) (*model.User, error)

GetUser will try to get an existing user in our database with the provided id.

func (*Users) UpdateUser

func (u *Users) UpdateUser(ctx context.Context, user *model.User) (*model.User, error)

UpdateUser will try to update an existing user in our database with the provided data.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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