models

package
v0.0.0-...-3bae08f Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BottleFilterByAccount

func BottleFilterByAccount(accountID int, originaldb *gorm.DB) func(db *gorm.DB) *gorm.DB

BottleFilterByAccount is a gorm filter for a Belongs To relationship.

Types

type Account

type Account struct {
	ID        int      `gorm:"primary_key"` // primary key
	Bottles   []Bottle // has many Bottles
	CreatedAt time.Time
	DeletedAt *time.Time
	Name      string
	UpdatedAt time.Time
}

Cellar Account

func (*Account) AccountToAccount

func (m *Account) AccountToAccount() *app.Account

AccountToAccount loads a Account and builds the default view of media type Account.

func (m *Account) AccountToAccountLink() *app.AccountLink

AccountToAccountLink loads a Account and builds the link view of media type Account.

func (*Account) AccountToAccountTiny

func (m *Account) AccountToAccountTiny() *app.AccountTiny

AccountToAccountTiny loads a Account and builds the tiny view of media type Account.

func (Account) TableName

func (m Account) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type AccountDB

type AccountDB struct {
	Db *gorm.DB
}

AccountDB is the implementation of the storage interface for Account.

func NewAccountDB

func NewAccountDB(db *gorm.DB) *AccountDB

NewAccountDB creates a new storage type.

func (*AccountDB) Add

func (m *AccountDB) Add(ctx context.Context, model *Account) error

Add creates a new record.

func (*AccountDB) DB

func (m *AccountDB) DB() interface{}

DB returns the underlying database.

func (*AccountDB) Delete

func (m *AccountDB) Delete(ctx context.Context, id int) error

Delete removes a single record.

func (*AccountDB) Get

func (m *AccountDB) Get(ctx context.Context, id int) (*Account, error)

Get returns a single Account as a Database Model This is more for use internally, and probably not what you want in your controllers

func (*AccountDB) List

func (m *AccountDB) List(ctx context.Context) ([]*Account, error)

List returns an array of Account

func (*AccountDB) ListAccount

func (m *AccountDB) ListAccount(ctx context.Context) []*app.Account

ListAccount returns an array of view: default.

func (m *AccountDB) ListAccountLink(ctx context.Context) []*app.AccountLink

ListAccountLink returns an array of view: link.

func (*AccountDB) ListAccountTiny

func (m *AccountDB) ListAccountTiny(ctx context.Context) []*app.AccountTiny

ListAccountTiny returns an array of view: tiny.

func (*AccountDB) OneAccount

func (m *AccountDB) OneAccount(ctx context.Context, id int) (*app.Account, error)

OneAccount loads a Account and builds the default view of media type Account.

func (m *AccountDB) OneAccountLink(ctx context.Context, id int) (*app.AccountLink, error)

OneAccountLink loads a Account and builds the link view of media type Account.

func (*AccountDB) OneAccountTiny

func (m *AccountDB) OneAccountTiny(ctx context.Context, id int) (*app.AccountTiny, error)

OneAccountTiny loads a Account and builds the tiny view of media type Account.

func (*AccountDB) TableName

func (m *AccountDB) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*AccountDB) Update

func (m *AccountDB) Update(ctx context.Context, model *Account) error

Update modifies a single record.

type AccountStorage

type AccountStorage interface {
	DB() interface{}
	List(ctx context.Context) ([]*Account, error)
	Get(ctx context.Context, id int) (*Account, error)
	Add(ctx context.Context, account *Account) error
	Update(ctx context.Context, account *Account) error
	Delete(ctx context.Context, id int) error

	ListAccount(ctx context.Context) []*app.Account
	OneAccount(ctx context.Context, id int) (*app.Account, error)

	ListAccountLink(ctx context.Context) []*app.AccountLink
	OneAccountLink(ctx context.Context, id int) (*app.AccountLink, error)

	ListAccountTiny(ctx context.Context) []*app.AccountTiny
	OneAccountTiny(ctx context.Context, id int) (*app.AccountTiny, error)
}

AccountStorage represents the storage interface.

type Bottle

type Bottle struct {
	ID        int `gorm:"primary_key"` // primary key
	AccountID int // Belongs To Account
	Color     string
	Country   *string
	CreatedAt time.Time
	DeletedAt *time.Time
	Name      string
	Rating    int
	Region    *string
	Review    *string
	Sweetness *int
	UpdatedAt time.Time
	Varietal  string
	Vineyard  string
	Vintage   int
	Account   Account
}

Bottle Model

func BottleFromBottlePayload

func BottleFromBottlePayload(payload *app.BottlePayload) *Bottle

BottleFromBottlePayload Converts source BottlePayload to target Bottle model only copying the non-nil fields from the source.

func BottleFromCreateBottlePayload

func BottleFromCreateBottlePayload(payload *app.CreateBottlePayload) *Bottle

BottleFromCreateBottlePayload Converts source CreateBottlePayload to target Bottle model only copying the non-nil fields from the source.

func (*Bottle) BottleToBottle

func (m *Bottle) BottleToBottle() *app.Bottle

BottleToBottle loads a Bottle and builds the default view of media type Bottle.

func (*Bottle) BottleToBottleFull

func (m *Bottle) BottleToBottleFull() *app.BottleFull

BottleToBottleFull loads a Bottle and builds the full view of media type Bottle.

func (*Bottle) BottleToBottleTiny

func (m *Bottle) BottleToBottleTiny() *app.BottleTiny

BottleToBottleTiny loads a Bottle and builds the tiny view of media type Bottle.

func (Bottle) TableName

func (m Bottle) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type BottleDB

type BottleDB struct {
	Db *gorm.DB
}

BottleDB is the implementation of the storage interface for Bottle.

func NewBottleDB

func NewBottleDB(db *gorm.DB) *BottleDB

NewBottleDB creates a new storage type.

func (*BottleDB) Add

func (m *BottleDB) Add(ctx context.Context, model *Bottle) error

Add creates a new record.

func (*BottleDB) DB

func (m *BottleDB) DB() interface{}

DB returns the underlying database.

func (*BottleDB) Delete

func (m *BottleDB) Delete(ctx context.Context, id int) error

Delete removes a single record.

func (*BottleDB) Get

func (m *BottleDB) Get(ctx context.Context, id int) (*Bottle, error)

Get returns a single Bottle as a Database Model This is more for use internally, and probably not what you want in your controllers

func (*BottleDB) List

func (m *BottleDB) List(ctx context.Context) ([]*Bottle, error)

List returns an array of Bottle

func (*BottleDB) ListBottle

func (m *BottleDB) ListBottle(ctx context.Context, accountID int) []*app.Bottle

ListBottle returns an array of view: default.

func (*BottleDB) ListBottleByYears

func (m *BottleDB) ListBottleByYears(ctx context.Context, accountID int, years []int) (bottles []*app.Bottle, err error)

ListBottleByYears returns an array of view: default.

func (*BottleDB) ListBottleFull

func (m *BottleDB) ListBottleFull(ctx context.Context, accountID int) []*app.BottleFull

ListBottleFull returns an array of view: full.

func (*BottleDB) ListBottleTiny

func (m *BottleDB) ListBottleTiny(ctx context.Context, accountID int) []*app.BottleTiny

ListBottleTiny returns an array of view: tiny.

func (*BottleDB) OneBottle

func (m *BottleDB) OneBottle(ctx context.Context, id int, accountID int) (*app.Bottle, error)

OneBottle loads a Bottle and builds the default view of media type Bottle.

func (*BottleDB) OneBottleFull

func (m *BottleDB) OneBottleFull(ctx context.Context, id int, accountID int) (*app.BottleFull, error)

OneBottleFull loads a Bottle and builds the full view of media type Bottle.

func (*BottleDB) OneBottleTiny

func (m *BottleDB) OneBottleTiny(ctx context.Context, id int, accountID int) (*app.BottleTiny, error)

OneBottleTiny loads a Bottle and builds the tiny view of media type Bottle.

func (*BottleDB) TableName

func (m *BottleDB) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*BottleDB) Update

func (m *BottleDB) Update(ctx context.Context, model *Bottle) error

Update modifies a single record.

func (*BottleDB) UpdateFromBottlePayload

func (m *BottleDB) UpdateFromBottlePayload(ctx context.Context, payload *app.BottlePayload, id int) error

UpdateFromBottlePayload applies non-nil changes from BottlePayload to the model and saves it

func (*BottleDB) UpdateFromCreateBottlePayload

func (m *BottleDB) UpdateFromCreateBottlePayload(ctx context.Context, payload *app.CreateBottlePayload, id int) error

UpdateFromCreateBottlePayload applies non-nil changes from CreateBottlePayload to the model and saves it

type BottleStorage

type BottleStorage interface {
	DB() interface{}
	List(ctx context.Context) ([]*Bottle, error)
	Get(ctx context.Context, id int) (*Bottle, error)
	Add(ctx context.Context, bottle *Bottle) error
	Update(ctx context.Context, bottle *Bottle) error
	Delete(ctx context.Context, id int) error

	ListBottle(ctx context.Context, accountID int) []*app.Bottle
	OneBottle(ctx context.Context, id int, accountID int) (*app.Bottle, error)

	ListBottleFull(ctx context.Context, accountID int) []*app.BottleFull
	OneBottleFull(ctx context.Context, id int, accountID int) (*app.BottleFull, error)

	ListBottleTiny(ctx context.Context, accountID int) []*app.BottleTiny
	OneBottleTiny(ctx context.Context, id int, accountID int) (*app.BottleTiny, error)

	BottleFromCreateBottlePayload(payload *app.CreateBottlePayload) *Bottle
	UpdateFromBottlePayload(ctx context.Context, payload *app.BottlePayload, id int) error
	UpdateFromCreateBottlePayload(ctx context.Context, payload *app.CreateBottlePayload, id int) error
}

BottleStorage represents the storage interface.

Jump to

Keyboard shortcuts

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