controllers

package
v0.0.0-...-2587fd7 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2016 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToAccountLink(account *AccountModel) *app.AccountLink

ToAccountLink builds an account link from an account model.

func ToAccountMedia

func ToAccountMedia(account *AccountModel) *app.Account

ToAccountMedia builds an account media type from an account model.

func ToBottleMedia

func ToBottleMedia(b *BottleModel) *app.Bottle

ToBottleMedia converts a bottle model into a bottle media type

func Watcher

func Watcher(accountID, bottleID int) websocket.Handler

Echo the data received on the WebSocket.

Types

type AccountController

type AccountController struct {
	*goa.Controller
	// contains filtered or unexported fields
}

AccountController implements the account resource.

func NewAccount

func NewAccount(service *goa.Service) *AccountController

NewAccount creates a account controller.

func (*AccountController) Create

Create records a new account.

func (*AccountController) Delete

Delete removes a account from the database.

func (*AccountController) Show

Show retrieves the account with the given id.

func (*AccountController) Update

Update updates a account field(s).

type AccountModel

type AccountModel struct {
	ID        int
	Href      string
	Name      string
	CreatedAt *string
	CreatedBy *string
}

AccountModel is the database "model" for accounts

type BottleController

type BottleController struct {
	*goa.Controller
	// contains filtered or unexported fields
}

BottleController implements the bottle resource.

func NewBottle

func NewBottle(service *goa.Service) *BottleController

NewBottle creates a bottle controller.

func (*BottleController) Create

Create records a new bottle.

func (*BottleController) Delete

Delete removes a bottle from the database.

func (*BottleController) List

List lists all the bottles in the account optionally filtering by year.

func (*BottleController) Rate

Rate rates a bottle.

func (*BottleController) Show

Show retrieves the bottle with the given id.

func (*BottleController) Update

Update updates a bottle field(s).

func (*BottleController) Watch

Watch watches the bottle with the given id.

type BottleModel

type BottleModel struct {
	ID        int
	Href      string
	Account   *AccountModel
	Name      string
	Kind      string
	Color     string
	Country   *string
	CreatedAt *string
	Rating    *int
	Region    *string
	Review    *string
	Sweetness *int
	UpdatedAt *string
	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(account *AccountModel)

DeleteAccount deletes the account.

func (*DB) DeleteBottle

func (db *DB) DeleteBottle(bottle *BottleModel)

DeleteBottle deletes bottle from bottlesbase.

func (*DB) GetAccount

func (db *DB) GetAccount(id int) *AccountModel

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

func (*DB) GetBottle

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

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() *AccountModel

NewAccount creates a new blank account resource.

func (*DB) NewBottle

func (db *DB) NewBottle(account int) *BottleModel

NewBottle creates a new bottle resource.

func (*DB) SaveAccount

func (db *DB) SaveAccount(a *AccountModel)

SaveAccount "persists" the account.

func (*DB) SaveBottle

func (db *DB) SaveBottle(b *BottleModel)

SaveBottle persists bottle to bottlesbase.

Jump to

Keyboard shortcuts

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