db

package
v0.0.0-...-d3a3332 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound       = errors.New("not found")
	ErrExists         = errors.New("exists")
	ErrNoUpdate       = errors.New("nothing to update")
	ErrNoPrimaryEmail = errors.New("no primary email was provided")
)

Functions

This section is empty.

Types

type DataStore

type DataStore interface {
	SetNewConnection(ctx context.Context, connStr string) error
	CreatePlant(ctx context.Context, p *Plant) (*Plant, error)
	UpdatePlant(ctx context.Context, p *Plant) (*Plant, error)
	GetPlantByID(ctx context.Context, id string) (*Plant, error)
	GetAllPlants(ctx context.Context) ([]*Plant, error)
	DeletePlant(ctx context.Context, id string) error
}

type DbInstance

type DbInstance struct {
	Pool *pgxpool.Pool
	// contains filtered or unexported fields
}

func Configure

func Configure(opts ...NewDbInstanceOpt) (*DbInstance, error)

func (*DbInstance) CreatePlant

func (i *DbInstance) CreatePlant(ctx context.Context, p *Plant) (*Plant, error)

func (*DbInstance) CreateUser

func (i *DbInstance) CreateUser(ctx context.Context, u *User) (*User, error)

func (*DbInstance) DeletePlant

func (i *DbInstance) DeletePlant(ctx context.Context, id string) error

func (*DbInstance) DeleteUser

func (i *DbInstance) DeleteUser(ctx context.Context, id string) error

func (*DbInstance) GetAllPlants

func (i *DbInstance) GetAllPlants(ctx context.Context) ([]*Plant, error)

GetAllProducts returns all products in the database

func (*DbInstance) GetPlantByID

func (i *DbInstance) GetPlantByID(ctx context.Context, id string) (*Plant, error)

func (*DbInstance) GetUserByEmail

func (i *DbInstance) GetUserByEmail(ctx context.Context, email string) (*User, error)

func (*DbInstance) GetUserByID

func (i *DbInstance) GetUserByID(ctx context.Context, id string) (*User, error)

func (*DbInstance) GetUserByPhone

func (i *DbInstance) GetUserByPhone(ctx context.Context, phone string) (*User, error)

func (*DbInstance) SetNewConnection

func (i *DbInstance) SetNewConnection(ctx context.Context, connStr string) error

func (*DbInstance) UpdatePlant

func (i *DbInstance) UpdatePlant(ctx context.Context, p *Plant) (*Plant, error)

func (*DbInstance) UpdateUser

func (i *DbInstance) UpdateUser(ctx context.Context, u *User) (*User, error)

type NewDbInstanceOpt

type NewDbInstanceOpt func(i *DbInstance) error

func WithNewConnection

func WithNewConnection(conn string) NewDbInstanceOpt

func WithPool

func WithPool(p *pgxpool.Pool) NewDbInstanceOpt

type Plant

type Plant struct {
	ID            string    `json:"id" db:"id"`
	Name          string    `json:"name" db:"name"`
	BotanicalName string    `json:"botanical_name" db:"botanical_name"`
	Description   string    `json:"description" db:"description"`
	WaterPref     string    `json:"water_pref" db:"water_pref"`
	LightPref     string    `json:"light_pref" db:"light_pref"`
	HumidityPref  string    `json:"humidity_pref" db:"humidity_pref"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
	DeletedAt     time.Time `json:"-"`
}

type User

type User struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	DisplayName string    `json:"display_name"`
	Email       string    `json:"email"`
	Phone       string    `json:"phone"`
	IdpID       string    `json:"-"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	DeletedAt   time.Time `json:"deleted_at"`
}

Jump to

Keyboard shortcuts

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