database

package
v0.0.0-...-e78e600 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Receive

func Receive() *gorm.DB

Receive the database instance pointer

func Serve

Serve call for the service registry

Types

type Address

type Address struct {
	gorm.Model
	City         string `json:"city"`
	PostCode     string `json:"postCode"`
	State        *State
	StateID      *uint  `sql:"type:integer REFERENCES states(id)" json:"-"`
	Street       string `json:"street"`
	StreetNumber string `json:"streetNumber"`
}

func (*Address) BeforeSave

func (address *Address) BeforeSave(db *gorm.DB) (err error)

Trigger for addresses, that ensures, that every addresses.state has a deliveryPrice and is only stored once in the database

type Category

type Category struct {
	gorm.Model
	Children []Category `gorm:"foreignkey:ParentID" json:"children"`
	Name     string     `json:"name"`
	Parent   *Category
	ParentID *uint   `sql:"type:integer REFERENCES categories(id)" json:"-"`
	Scores   []Score `gorm:"foreignkey:CategoryID" json:"scores"`
}

func (Category) MarshalJSON

func (c Category) MarshalJSON() ([]byte, error)

type CategoryJSON

type CategoryJSON struct {
	gorm.Model
	Children      []Category `json:"children"`
	Name          string     `json:"name"`
	Parent        *Category
	Scores        []Score `json:"scores"`
	SanitizedName string  `json:"sanitizedName"`
}

type Order

type Order struct {
	gorm.Model
	BillingAddress    *Address `json:"billingAddress"`
	BillingAddressID  uint     `sql:"type:integer REFERENCES addresses(id)" json:"-"`
	BillingDate       int64    `json:"billingDate"`
	Company           string   `json:"company"`
	Date              int64    `json:"date"`
	DeliveryAddress   *Address `json:"deliveryAddress"`
	DeliveryAddressID uint     `sql:"type:integer REFERENCES addresses(id)" json:"-"`
	Email             string   `json:"email"`
	FirstName         string   `json:"firstName"`
	LastName          string   `json:"lastName"`
	Payed             bool     `json:"payed"`
	ReferenceCount    int      `json:"referenceCount"`
	Salutation        string   `json:"salutation"`
	Score             Score    `json:"score"`
	ScoreID           uint     `sql:"type:integer REFERENCES scores(id)" json:"scoreId"`
	ScoreAmount       int      `json:"scoreAmount"`
	Telephone         string   `json:"telephone"`
}

func (*Order) BeforeSave

func (order *Order) BeforeSave(db *gorm.DB) (err error)

Hook for generating BillingDate and ReferenceCount before Order is saved to the database

type Score

type Score struct {
	gorm.Model
	Category   *Category
	CategoryID uint    `sql:"type:integer REFERENCES categories(id)" json:"-"`
	Difficulty int     `json:"difficulty"`
	Price      float64 `json:"price"`
	Title      string  `json:"title"`
}

func (Score) MarshalJSON

func (s Score) MarshalJSON() ([]byte, error)

type ScoreJSON

type ScoreJSON struct {
	gorm.Model
	Category      *Category
	Difficulty    int     `json:"difficulty"`
	Price         float64 `json:"price"`
	Title         string  `json:"title"`
	SanitizedName string  `json:"sanitizedName"`
}

type State

type State struct {
	gorm.Model
	Name          string  `json:"name"`
	DeliveryPrice float64 `json:"deliveryPrice"`
}

type User

type User struct {
	*UserWithoutPassword
	Password string `json:"password"`
}

type UserWithoutPassword

type UserWithoutPassword struct {
	gorm.Model
	Email      string `gorm:"primary_key" json:"email"`
	Admin      bool   `json:"admin"`
	Name       string `json:"name"`
	LastChange int    `json:"lastChange"`
	LastLogin  int    `json:"lastLogin"`
}

Jump to

Keyboard shortcuts

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