model

package
v0.0.0-...-f44a32d Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2020 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DBMigrate

func DBMigrate(db *gorm.DB) *gorm.DB

DBMigrate will create and migrate the tables, and then make the some relationships if necessary

Types

type Product

type Product struct {
	ID    uint    `gorm:"primary_key" json:"product_id"`
	Name  string  `gorm:"not null" json:"name"`
	Price float64 `gorm:"default:0" json:"price"`
}

type Ticket

type Ticket struct {
	ID uint `json:"id"`

	Hash      string    `json:"hash"`
	TxHash    string    `json:"tx_hash"`
	Timestamp time.Time `json:"timestamp"`
	Seller    *User     `gorm:"foreignkey:SellerID; PRELOAD:true"`
	SellerID  string    `json:"seller"`
	BuyerID   string    `json:"buyer"`

	TicketProducts []*TicketProduct `gorm:"ForeignKey:TicketID" json:"products"`
}

type TicketProduct

type TicketProduct struct {
	TicketID  uint `gorm:"primary_key" json:"ticket_hash"`
	Product   *Product
	ProductID uint `gorm:"primary_key; auto_increment:false" json:"product_id"`

	Amount uint `json:"amount"`
}

func (*TicketProduct) TableName

func (*TicketProduct) TableName() string

type User

type User struct {
	PublicKey string `gorm:"primary_key" json:"public_key"`
	Name      string `gorm:"not null" json:"name"`
	Email     string `gorm:"not null" json:"email"`
	NIF       string `gorm:"not null" json:"nif"`
	Role      string `gorm:"not null"`
}

Jump to

Keyboard shortcuts

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