models

package
v0.0.0-...-263c6a4 Latest Latest
Warning

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

Go to latest
Published: May 4, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(db *gorm.DB)

Create datbase models using ORM

func Drop

func Drop(db *gorm.DB)

Drop datbase models using ORM

func Migrate

func Migrate(db *gorm.DB)

Migrate automigrates models using ORM

Types

type Address

type Address struct {
	// gorm.Model
	ID           uint `gorm:"primary_key"`
	Street       string
	StreetNumber string
	PostalCode   string
	City         string
	Country      string
	PlusCode     string
	Coordinate   string
	RidersID     uint
	EventsID     uint
}

Address data model

func (Address) Serialize

func (p Address) Serialize() common.JSON

Serialize serializes post data

type Class

type Class struct {
	//gorm.Model
	ID   uint
	Name string `gorm:"not null"`
}

Class data model

func (Class) Serialize

func (p Class) Serialize() common.JSON

Serialize serializes post data

type Event

type Event struct {
	ID            uint   `gorm:"primary_key"`
	Name          string `gorm:"not null"`
	Date          string `gorm:"not null"`
	TotalStages   int    `gorm:"not null"`
	AddressesID   uint
	Addresses     Address `gorm:"foreignkey:EventsID;association_foreignkey:AddressesID"`
	TypeOfRacesID uint
	TypeOfRaces   TypeOfRace `gorm:"foreignkey:EventsID;association_foreignkey:TypeOfRacesID"` // One-To-One relationship (has one)
	SeasonsID     uint
	Seasons       Season `gorm:"foreignkey:EventsID;association_foreignkey:SeasonsID"` //;association_foreignkey:ID"
	StagesID      uint
	Stages        []Stage `gorm:"foreignkey:EventsID;association_foreignkey:StagesID"` // ;association_foreignkey:ID

}

Event data model

func (Event) Serialize

func (p Event) Serialize() common.JSON

Serialize serializes post data

type Post

type Post struct {
	gorm.Model
	Text   string `sql:"type:text;"`
	User   User   `gorm:"foreignkey:UserID"`
	UserID uint
}

Post data model

func (Post) Serialize

func (p Post) Serialize() common.JSON

Serialize serializes post data

type Registered

type Registered struct {
	ID          uint `gorm:"primary_key"`
	Date        time.Time
	StartNumber string
	RidersID    uint
	Riders      Rider `gorm:"ForeignKey:ID;association_foreignkey:RidersID"`
	EventsID    uint
	Events      Event `gorm:"ForeignKey:ID;association_foreignkey:EventsID"`
	ClassID     uint
	Class       Class `gorm:"foreignkey:ID;association_foreignkey:ClassID"`
}

Registered data model

func (Registered) Serialize

func (p Registered) Serialize() common.JSON

Serialize serializes post data

type Result

type Result struct {
	ID        uint `gorm:"primary_key"`
	TotalTime time.Time
	Place     uint
	RidersID  uint
	EventsID  uint
	Events    Event `gorm:"ForeignKey:ID;association_foreignkey:EventsID"`
}

Result data model

func (Result) Serialize

func (p Result) Serialize() common.JSON

Serialize serializes post data

type Rider

type Rider struct {
	// gorm.Model
	ID          uint      `gorm:"primary_key"`
	Firstname   string    `gorm:"not null"`
	Lastname    string    `gorm:"not null"`
	Gender      int       `gorm:"not null"`
	Mail        string    `gorm:"not null"`
	Birthday    time.Time `gorm:"not null"`
	AddressesID uint
	Addresses   Address `gorm:"ForeignKey:ID;association_foreignkey:AddressesID"`
	RunsID      uint
	Runs        []Run `gorm:"ForeignKey:RidersID;association_foreignkey:RunsID"`
	ResultsID   uint
	Results     Result `gorm:"ForeignKey:RidersID;association_foreignkey:ResultsID"`
	StagesID    uint
	Stages      []Stage `gorm:"ForeignKey:ID;association_foreignkey:StagesID"`
}

Rider data model

func (Rider) Serialize

func (p Rider) Serialize() common.JSON

Serialize serializes post data

type Run

type Run struct {
	ID        uint `gorm:"primary_key"`
	StartTime time.Time
	EndTime   time.Time
	DNF       bool
	RidersID  uint
	EventsID  uint
	StagesID  uint
}

Run data model

func (Run) Serialize

func (p Run) Serialize() common.JSON

Serialize serializes post data

type Season

type Season struct {
	ID       uint   `gorm:"primary_key"` //	gorm.Model
	Name     string `gorm:"not null"`
	Year     uint   `gorm:"not null"`
	EventsID uint
}

Season data model

func (Season) Serialize

func (p Season) Serialize() common.JSON

Serialize serializes post data

type Stage

type Stage struct {
	ID       uint   `gorm:"primary_key"`
	Name     string `gorm:"not null"`
	Location string `gorm:"not null"`
	Order    uint   `gorm:"not null"`
	EventsID uint
}

Stage data model

func (Stage) Serialize

func (p Stage) Serialize() common.JSON

Serialize serializes post data

type TypeOfRace

type TypeOfRace struct {
	ID       uint   `gorm:"primary_key"` //	gorm.Model
	Name     string `gorm:"not null"`
	EventsID uint
}

TypeOfRace data model

func (TypeOfRace) Serialize

func (p TypeOfRace) Serialize() common.JSON

Serialize serializes post data

type User

type User struct {
	gorm.Model
	Username     string `gorm:"column:username;not null"`
	PasswordHash string `gorm:"column:password;not null"`
	DisplayName  string `gorm:"not null"`
}

User data model

func (User) Serialize

func (p User) Serialize() common.JSON

Serialize serializes post data

type UserAccess

type UserAccess struct {
	gorm.Model
	SourceID uint
	Role     string `gorm:"not null"`
}

UserAccess data model

func (UserAccess) Serialize

func (p UserAccess) Serialize() common.JSON

Serialize serializes post data

Jump to

Keyboard shortcuts

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