storage

package
v0.0.0-...-b631e0d Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec() error

Exec initializes storage, then performs operations using the storage interface

func PerformOperations

func PerformOperations(s Storage) error

PerformOperations creates a candle item then gets it

Types

type Item

type Item struct {
	Name  string
	Price int64
}

Item represents an item at a shop

type MongoStorage

type MongoStorage struct {
	*mgo.Session
	DB         string
	Collection string
}

MongoStorage implements our storage interface

func NewMongoStorage

func NewMongoStorage(connection, db, collection string) (*MongoStorage, error)

NewMongoStorage initializes a MongoStorage

func (*MongoStorage) GetByName

func (m *MongoStorage) GetByName(ctx context.Context, name string) (*Item, error)

GetByName queries mongodb for an item with the correct name

func (*MongoStorage) Put

func (m *MongoStorage) Put(ctx context.Context, i *Item) error

Put adds an item to our mongo instance

type Storage

type Storage interface {
	GetByName(context.Context, string) (*Item, error)
	Put(context.Context, *Item) error
}

Storage is our storage interface We'll implement it with Mongo storage

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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