database

package
v0.0.0-...-34d2590 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorEnvVar = fmt.Errorf("missing environment variable")

ErrorEnvVar : Environment variable error

Functions

This section is empty.

Types

type MockProducts

type MockProducts struct {
}

func (*MockProducts) AddProduct

func (mp *MockProducts) AddProduct(ctx context.Context, product *data.Product) error

func (*MockProducts) CloseDB

func (mp *MockProducts) CloseDB()

func (*MockProducts) Connect

func (mp *MockProducts) Connect() error

func (*MockProducts) DeleteProduct

func (mp *MockProducts) DeleteProduct(ctx context.Context, id string) error

func (*MockProducts) GetProductByID

func (mp *MockProducts) GetProductByID(ctx context.Context, id string) (*data.Product, error)

func (*MockProducts) GetProducts

func (mp *MockProducts) GetProducts(ctx context.Context) data.Products

func (*MockProducts) PingDB

func (mp *MockProducts) PingDB() error

func (*MockProducts) UpdateProduct

func (mp *MockProducts) UpdateProduct(ctx context.Context, product *data.Product) error

type MongoProducts

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

func (*MongoProducts) AddProduct

func (mp *MongoProducts) AddProduct(ctx context.Context, product *data.Product) error

func (*MongoProducts) CloseDB

func (mp *MongoProducts) CloseDB()

func (*MongoProducts) Connect

func (mp *MongoProducts) Connect() error

func (*MongoProducts) DeleteProduct

func (mp *MongoProducts) DeleteProduct(ctx context.Context, id string) error

func (*MongoProducts) GetProductByID

func (mp *MongoProducts) GetProductByID(ctx context.Context, id string) (*data.Product, error)

func (*MongoProducts) GetProducts

func (mp *MongoProducts) GetProducts(ctx context.Context) data.Products

func (*MongoProducts) PingDB

func (mp *MongoProducts) PingDB() error

func (*MongoProducts) UpdateProduct

func (mp *MongoProducts) UpdateProduct(ctx context.Context, product *data.Product) error

type ProductDB

type ProductDB interface {
	GetProducts(ctx context.Context) data.Products
	GetProductByID(ctx context.Context, id string) (*data.Product, error)
	UpdateProduct(ctx context.Context, product *data.Product) error
	AddProduct(ctx context.Context, product *data.Product) error
	DeleteProduct(ctx context.Context, id string) error
	Connect() error
	PingDB() error
	CloseDB()
}

The interface that any kind of database must implement

func NewMockProducts

func NewMockProducts() ProductDB

func NewMongoProducts

func NewMongoProducts() ProductDB

Jump to

Keyboard shortcuts

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