repository

package
v0.0.0-...-02249b2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	DB *sqlx.DB
}

Options is a utility to define all dependencies and parameters to inject

type Repository

type Repository struct {
	UserRepository *UserRepository
}

Repository combines all repositories

func CreateRepository

func CreateRepository(options *Options) (*Repository, error)

CreateRepository create a implementation of repository with all injected dependencies

type UserRepository

type UserRepository struct {
	DB *sqlx.DB
}

UserRepository is a repository implementation of service layer UserRepository interface

func (*UserRepository) Create

func (r *UserRepository) Create(ctx context.Context, u *model.User) (*model.User, error)

Create a user

func (*UserRepository) Delete

func (r *UserRepository) Delete(ctx context.Context, id string) error

Delete a user

func (*UserRepository) GetAll

func (r *UserRepository) GetAll(ctx context.Context, name string) ([]model.User, error)

GetAll returns all users or error

func (*UserRepository) GetByID

func (r *UserRepository) GetByID(ctx context.Context, id uuid.UUID) (*model.User, error)

GetByID fetches user by ID or return error

func (*UserRepository) Update

func (r *UserRepository) Update(ctx context.Context, u *model.User) (*model.User, error)

Update a user

Jump to

Keyboard shortcuts

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