Documentation ¶
Index ¶
- Variables
- type MockProducts
- func (mp *MockProducts) AddProduct(ctx context.Context, product *data.Product) error
- func (mp *MockProducts) CloseDB()
- func (mp *MockProducts) Connect() error
- func (mp *MockProducts) DeleteProduct(ctx context.Context, id string) error
- func (mp *MockProducts) GetProductByID(ctx context.Context, id string) (*data.Product, error)
- func (mp *MockProducts) GetProducts(ctx context.Context) data.Products
- func (mp *MockProducts) PingDB() error
- func (mp *MockProducts) UpdateProduct(ctx context.Context, product *data.Product) error
- type MongoProducts
- func (mp *MongoProducts) AddProduct(ctx context.Context, product *data.Product) error
- func (mp *MongoProducts) CloseDB()
- func (mp *MongoProducts) Connect() error
- func (mp *MongoProducts) DeleteProduct(ctx context.Context, id string) error
- func (mp *MongoProducts) GetProductByID(ctx context.Context, id string) (*data.Product, error)
- func (mp *MongoProducts) GetProducts(ctx context.Context) data.Products
- func (mp *MongoProducts) PingDB() error
- func (mp *MongoProducts) UpdateProduct(ctx context.Context, product *data.Product) error
- type ProductDB
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 (*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 (*MockProducts) GetProducts ¶
func (mp *MockProducts) GetProducts(ctx context.Context) data.Products
func (*MockProducts) PingDB ¶
func (mp *MockProducts) PingDB() error
func (*MockProducts) UpdateProduct ¶
type MongoProducts ¶
type MongoProducts struct {
// contains filtered or unexported fields
}
func (*MongoProducts) AddProduct ¶
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 (*MongoProducts) GetProducts ¶
func (mp *MongoProducts) GetProducts(ctx context.Context) data.Products
func (*MongoProducts) PingDB ¶
func (mp *MongoProducts) PingDB() error
func (*MongoProducts) UpdateProduct ¶
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
Click to show internal directories.
Click to hide internal directories.