store

package
v0.0.0-...-a32827f Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountModel

type AccountModel struct {
	ID        int
	Name      string
	CreatedAt time.Time
	CreatedBy string
}

AccountModel is the database "model" for accounts

type BottleModel

type BottleModel struct {
	ID        int
	AccountID int
	Name      string
	Kind      string
	Color     string
	Country   *string
	CreatedAt time.Time
	Rating    *int
	Region    *string
	Review    *string
	Sweetness *int
	UpdatedAt time.Time
	Varietal  string
	Vineyard  string
	Vintage   int
}

BottleModel is the database "model" for bottles

type DB

type DB struct {
	sync.Mutex
	// contains filtered or unexported fields
}

DB emulates a database driver using in-memory data structures.

func NewDB

func NewDB() *DB

NewDB initializes a new "DB" with dummy data.

func (*DB) DeleteAccount

func (db *DB) DeleteAccount(model AccountModel)

DeleteAccount deletes the account.

func (*DB) DeleteBottle

func (db *DB) DeleteBottle(model BottleModel)

DeleteBottle deletes bottle from bottlesbase.

func (*DB) GetAccount

func (db *DB) GetAccount(id int) (model AccountModel, ok bool)

GetAccount returns the account with given id if any, nil otherwise.

func (*DB) GetAccounts

func (db *DB) GetAccounts() []AccountModel

GetAccounts returns all the accounts.

func (*DB) GetBottle

func (db *DB) GetBottle(account, id int) (model BottleModel, ok bool)

GetBottle returns the bottle with the given id from the given account or nil if not found.

func (*DB) GetBottles

func (db *DB) GetBottles(account int) ([]BottleModel, error)

GetBottles return the bottles from the given account.

func (*DB) GetBottlesByYears

func (db *DB) GetBottlesByYears(account int, years []int) ([]BottleModel, error)

GetBottlesByYears returns the bottles with the vintage in the given array from the given account.

func (*DB) NewAccount

func (db *DB) NewAccount() (model AccountModel)

NewAccount creates a new blank account resource.

func (*DB) NewBottle

func (db *DB) NewBottle(account int) (model BottleModel, err error)

NewBottle creates a new bottle resource.

func (*DB) Reset

func (db *DB) Reset()

Reset removes all entries from the database. Mainly intended for tests.

func (*DB) SaveAccount

func (db *DB) SaveAccount(model AccountModel)

SaveAccount "persists" the account.

func (*DB) SaveBottle

func (db *DB) SaveBottle(model BottleModel)

SaveBottle persists bottle to bottlesbase.

Jump to

Keyboard shortcuts

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