models

package
v0.0.0-...-c65c6a6 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BottleCategoryFilterByBottle

func BottleCategoryFilterByBottle(bottleID int, originaldb *gorm.DB) func(db *gorm.DB) *gorm.DB

BottleCategoryFilterByBottle is a gorm filter for a Belongs To relationship.

func BottleCategoryFilterByCategory

func BottleCategoryFilterByCategory(categoryID int, originaldb *gorm.DB) func(db *gorm.DB) *gorm.DB

BottleCategoryFilterByCategory is a gorm filter for a Belongs To relationship.

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
	Email     string
	Name      string
	CreatedAt time.Time  // timestamp
	DeletedAt *time.Time // nullable timestamp (soft delete)
	UpdatedAt time.Time  // timestamp
}

celler account

func (*Account) AccountToAccount

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

AccountToAccount loads a Account and builds the default 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 (*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 (*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)
}

AccountStorage represents the storage interface.

type Bottle

type Bottle struct {
	ID               int              `gorm:"primary_key"` // primary key
	AccountID        int              // Belongs To Account
	BottleCategories []BottleCategory // has many BottleCategories
	Categories       []Category       `gorm:"many2many:bottle_categories"` // many to many Bottle/Category
	Name             string
	Quantity         int
	CreatedAt        time.Time  // timestamp
	DeletedAt        *time.Time // nullable timestamp (soft delete)
	UpdatedAt        time.Time  // timestamp
	Account          Account
}

celler bottle

func (*Bottle) BottleToBottle

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

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

func (*Bottle) BottleToBottleRelation

func (m *Bottle) BottleToBottleRelation() *app.BottleRelation

BottleToBottleRelation loads a Bottle and builds the relation 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 BottleCategory

type BottleCategory struct {
	ID         int        `gorm:"primary_key"` // primary key
	BottleID   int        // Belongs To Bottle
	CategoryID int        // has many BottleCategory
	CreatedAt  time.Time  // timestamp
	DeletedAt  *time.Time // nullable timestamp (soft delete)
	UpdatedAt  time.Time  // timestamp
	Bottle     Bottle
	Category   Category
}

celler bottle category

func (BottleCategory) TableName

func (m BottleCategory) TableName() string

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

type BottleCategoryDB

type BottleCategoryDB struct {
	Db *gorm.DB
}

BottleCategoryDB is the implementation of the storage interface for BottleCategory.

func NewBottleCategoryDB

func NewBottleCategoryDB(db *gorm.DB) *BottleCategoryDB

NewBottleCategoryDB creates a new storage type.

func (*BottleCategoryDB) Add

func (m *BottleCategoryDB) Add(ctx context.Context, model *BottleCategory) error

Add creates a new record.

func (*BottleCategoryDB) DB

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

DB returns the underlying database.

func (*BottleCategoryDB) Delete

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

Delete removes a single record.

func (*BottleCategoryDB) Get

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

func (*BottleCategoryDB) List

List returns an array of BottleCategory

func (*BottleCategoryDB) TableName

func (m *BottleCategoryDB) TableName() string

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

func (*BottleCategoryDB) Update

func (m *BottleCategoryDB) Update(ctx context.Context, model *BottleCategory) error

Update modifies a single record.

type BottleCategoryStorage

type BottleCategoryStorage interface {
	DB() interface{}
	List(ctx context.Context) ([]*BottleCategory, error)
	Get(ctx context.Context, id int) (*BottleCategory, error)
	Add(ctx context.Context, bottlecategory *BottleCategory) error
	Update(ctx context.Context, bottlecategory *BottleCategory) error
	Delete(ctx context.Context, id int) error
}

BottleCategoryStorage represents the storage interface.

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) ListBottleFullScan

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

ListBottle returns an array of view: default.

func (*BottleDB) ListBottleRelation

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

ListBottleRelation returns an array of view: relation.

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) OneBottleRelation

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

OneBottleRelation loads a Bottle and builds the relation 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.

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)

	ListBottleRelation(ctx context.Context, accountID int) []*app.BottleRelation
	OneBottleRelation(ctx context.Context, id int, accountID int) (*app.BottleRelation, error)
}

BottleStorage represents the storage interface.

type Category

type Category struct {
	ID               int              `gorm:"primary_key"` // primary key
	BottleCategories []BottleCategory // has many BottleCategories
	Bottles          []Bottle         `gorm:"many2many:Bottles"` // many to many Category/Bottle
	Name             string
	CreatedAt        time.Time  // timestamp
	DeletedAt        *time.Time // nullable timestamp (soft delete)
	UpdatedAt        time.Time  // timestamp
}

celler category

func (*Category) CategoryToCategory

func (m *Category) CategoryToCategory() *app.Category

CategoryToCategory loads a Category and builds the default view of media type Category.

func (Category) TableName

func (m Category) TableName() string

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

type CategoryDB

type CategoryDB struct {
	Db *gorm.DB
}

CategoryDB is the implementation of the storage interface for Category.

func NewCategoryDB

func NewCategoryDB(db *gorm.DB) *CategoryDB

NewCategoryDB creates a new storage type.

func (*CategoryDB) Add

func (m *CategoryDB) Add(ctx context.Context, model *Category) error

Add creates a new record.

func (*CategoryDB) DB

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

DB returns the underlying database.

func (*CategoryDB) Delete

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

Delete removes a single record.

func (*CategoryDB) Get

func (m *CategoryDB) Get(ctx context.Context, id int) (*Category, error)

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

func (*CategoryDB) List

func (m *CategoryDB) List(ctx context.Context) ([]*Category, error)

List returns an array of Category

func (*CategoryDB) ListCategory

func (m *CategoryDB) ListCategory(ctx context.Context) []*app.Category

ListCategory returns an array of view: default.

func (*CategoryDB) OneCategory

func (m *CategoryDB) OneCategory(ctx context.Context, id int) (*app.Category, error)

OneCategory loads a Category and builds the default view of media type Category.

func (*CategoryDB) TableName

func (m *CategoryDB) TableName() string

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

func (*CategoryDB) Update

func (m *CategoryDB) Update(ctx context.Context, model *Category) error

Update modifies a single record.

type CategoryStorage

type CategoryStorage interface {
	DB() interface{}
	List(ctx context.Context) ([]*Category, error)
	Get(ctx context.Context, id int) (*Category, error)
	Add(ctx context.Context, category *Category) error
	Update(ctx context.Context, category *Category) error
	Delete(ctx context.Context, id int) error

	ListCategory(ctx context.Context) []*app.Category
	OneCategory(ctx context.Context, id int) (*app.Category, error)
}

CategoryStorage represents the storage interface.

Jump to

Keyboard shortcuts

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