repo

package
v0.0.0-...-625d9dc Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package repo contains implementations of the repository interfaces

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound error = errors.New("user not found")

ErrNotFound user not found.

Functions

This section is empty.

Types

type PG

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

PG ...

func NewPG

func NewPG(ctx context.Context, url string, debug bool) (*PG, error)

NewPG builder fog postgres implementation of the repo interface.

func (*PG) DeleteGarden

func (pg *PG) DeleteGarden(ctx context.Context, gardenID int64) error

DeleteGarden deletes garden from db by specified id.

func (*PG) DeleteUserPlant

func (pg *PG) DeleteUserPlant(ctx context.Context, userPlantID int64) error

DeleteUserPlant delete user's plant by id.

func (*PG) FindGardenByID

func (pg *PG) FindGardenByID(ctx context.Context, gardenID int64) (*models.Garden, error)

FindGardenByID extracts garden from db by specified id.

func (*PG) FindUserByLogin

func (pg *PG) FindUserByLogin(ctx context.Context, login string) (*models.User, []byte, error)

FindUserByLogin extracts user from db by specified username.

func (*PG) GetRefPlantByID

func (pg *PG) GetRefPlantByID(ctx context.Context, id int64) (*models.RefPlant, error)

GetRefPlantByID extracts reference.plant by specified id.

func (*PG) GetRefPlants

func (pg *PG) GetRefPlants(ctx context.Context,
	params refplant.GetRefPlantsParams) ([]*models.RefPlant, int64, int64, error)

GetRefPlans extracts all plants from the reference by parameters.

func (*PG) GetUserPlantByID

func (pg *PG) GetUserPlantByID(ctx context.Context, userPlantID int64) (*models.UserPlant, error)

GetUserPlantByID get user's plant by id from db.

func (*PG) Health

func (pg *PG) Health(ctx context.Context) error

Health checks availability postgres.

func (*PG) ListGarden

func (pg *PG) ListGarden(ctx context.Context, garden *models.Garden) ([]models.Garden, error)

ListGarden shows a list of user's gardens.

func (*PG) ListUserPlants

func (pg *PG) ListUserPlants(ctx context.Context,
	userID, limit, offset int64) ([]*models.UserPlant, error)

ListUserPlants get all user's plants from db.

func (*PG) StoreGarden

func (pg *PG) StoreGarden(ctx context.Context, garden *models.Garden) (*models.Garden, error)

StoreGarden inserts new garden to public.gardens.

func (*PG) StorePlant

func (pg *PG) StorePlant(ctx context.Context, plant *models.UserPlant) (*models.UserPlant, error)

StorePlant create new user's plant.

func (*PG) StoreUser

func (pg *PG) StoreUser(ctx context.Context, user *models.User, passwordHash []byte) (*models.User, error)

StoreUser inserts new user to db, with passhash.

func (*PG) UpdateUserPlant

func (pg *PG) UpdateUserPlant(ctx context.Context, plant *models.UserPlant) (*models.UserPlant, error)

UpdateUserPlant update user's plant.

Jump to

Keyboard shortcuts

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