Version: v0.0.0-...-6bf1803 Latest Latest

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

Go to latest
Published: Nov 17, 2020 License: Apache-2.0 Imports: 4 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type CartItem

type CartItem struct {
	ID       string        `json:"id"`
	Products map[uint]uint `json:"products"`

func NewCartItem

func NewCartItem(user string, product uint, quantity uint) (*CartItem, error)

func (CartItem) Validate

func (c CartItem) Validate() error

type CartStore

type CartStore interface {
	AddProduct(userID string, prodID uint, quantity uint) (uint, error)
	GetProductsForUser(userID string) (map[uint]uint, error)
	ClearCartFor(userID string) error

CartStore represents the shopping cart store

func New

func New(log logger, db UnderlyingStore) CartStore

New start a new instance of cart store

type ShoppingCartTable

type ShoppingCartTable struct {
	// contains filtered or unexported fields

ShoppingCartTable the shopping cart table schema

func GetTable

func GetTable() *ShoppingCartTable

func (*ShoppingCartTable) GetName

func (u *ShoppingCartTable) GetName() string

GetName returns the name of the shopping cart table

func (*ShoppingCartTable) GetTableSchema

func (u *ShoppingCartTable) GetTableSchema() *memdb.TableSchema

GetTableSchema returns the schema of the shopping cart table

type UnderlyingStore

type UnderlyingStore interface {
	Read(table string, key string, value interface{}) (interface{}, error)
	Write(table string, objs ...interface{}) error
	Remove(table string, key string, value interface{}) error

UnderlyingStore represents the interface that the DB should implement to be usable

type Validatable

type Validatable interface {
	Validate() error

Validatable is an item which has to adhere to certain convetions and knows how to check that it is correct

Source Files

Jump to

Keyboard shortcuts

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