db

package
v0.0.0-...-6746b86 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package db provides products database functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Db

type Db interface {
	GetProduct(id string) *model.Product
	GetAllProducts() []*model.Product
}

type DbImpl

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

DbImpl is a memory mocked abstraction of a database, real case scenarios should provide an api for external databases

func NewDbImpl

func NewDbImpl() *DbImpl

NewDbImpl returns a new *DbImpl instance

func (*DbImpl) GetAllProducts

func (db *DbImpl) GetAllProducts() []*model.Product

GetAllProducts return all the products present in the db

func (*DbImpl) GetProduct

func (db *DbImpl) GetProduct(code string) *model.Product

type MemDb

type MemDb interface {
	SaveBasket(id string, b *model.Basket)
	GetBasket(id string) *model.Basket
	DeleteBasket(id string)
}

type MemDbImpl

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

func NewMemDbImpl

func NewMemDbImpl() *MemDbImpl

func (*MemDbImpl) DeleteBasket

func (m *MemDbImpl) DeleteBasket(id string)

func (*MemDbImpl) GetBasket

func (m *MemDbImpl) GetBasket(id string) *model.Basket

func (*MemDbImpl) SaveBasket

func (m *MemDbImpl) SaveBasket(id string, b *model.Basket)

type PromotionDb

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

func NewPromotionsDb

func NewPromotionsDb() PromotionDb

func (*PromotionDb) GetStrategies

func (pdb *PromotionDb) GetStrategies() []model.DiscountCalculator

Jump to

Keyboard shortcuts

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