user

package
v0.0.0-...-7c6bf0a Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseRepository

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

DatabaseRepository implements the UserRepository interface.

func NewDatabaseRepository

func NewDatabaseRepository(db *pgxpool.Pool) *DatabaseRepository

NewDatabaseRepository returns a new DatabaseRepository.

func (*DatabaseRepository) Add

func (repo *DatabaseRepository) Add(ctx context.Context, name string) (int, error)

Add inserts a new user into the database and returns its id.

func (*DatabaseRepository) FetchAll

func (repo *DatabaseRepository) FetchAll(ctx context.Context) ([]app.User, error)

FetchAll returns all users.

func (*DatabaseRepository) FetchByID

func (repo *DatabaseRepository) FetchByID(ctx context.Context, id int) (*app.User, error)

FetchByID returns the user with the provided id. A nil value is returned if the user does not exist.

func (*DatabaseRepository) Ping

func (repo *DatabaseRepository) Ping(ctx context.Context) error

Ping checks if database is up.

type Service

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

Service wraps the user repository.

func NewService

func NewService(repo app.UserRepository) *Service

NewService returns a new Service.

func (*Service) Add

func (s *Service) Add(ctx context.Context, name string) (int, error)

Add inserts a new user and returns its id.

func (*Service) Health

func (s *Service) Health(ctx context.Context) app.Health

Health returns health check information.

func (*Service) User

func (s *Service) User(ctx context.Context, id int) (*app.User, error)

User returns the user with the provided id.

func (*Service) Users

func (s *Service) Users(ctx context.Context) ([]app.User, error)

Users returns all application users. Pagination should be implemented when the number of users grows.

Jump to

Keyboard shortcuts

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