models

package
v0.0.0-...-71093af Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	// format: uuid
	// example: "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
	ID        uuid.UUID  `json:"id" gorm:"type:uuid;primary_key;"`
	CreatedAt time.Time  `json:"createdAt" gorm:"column:createdAt"`
	UpdatedAt time.Time  `json:"updatedAt" gorm:"column:updatedAt"`
	DeletedAt *time.Time `json:"deletedAt" gorm:"column:deletedAt"`
}

Base structure for all the models.

func (*Base) BeforeCreate

func (base *Base) BeforeCreate(scope *gorm.Scope) error

BeforeCreate will set a UUID for each new record.

type Character

type Character struct {
	Base
	FirstName string `json:"firstName" gorm:"column:firstName" validate:"required"`
	LastName  string `json:"lastName" gorm:"column:lastName" validate:"required"`
	Nickname  string `json:"nickname" validate:"required"`
	Items     []Item `json:"items"`
}

Character model.

type CharactersResponse

type CharactersResponse struct {
	Total      int16       `json:"total"`
	Characters []Character `json:"characters"`
	Link       Link        `json:"link"`
}

CharactersResponse for the http request.

type Item

type Item struct {
	Base
	Type            string  `json:"type" validate:"required"`
	Length          float32 `json:"length" validate:"required"`
	Characteristics string  `json:"characteristics" validate:"required"`
	Manufacturer    string  `json:"manufacturer"`
}

Item model.

type ItemsResponse

type ItemsResponse struct {
	Total int16  `json:"total"`
	Items []Item `json:"items"`
	Link  Link   `json:"link"`
}

ItemsResponse for the http request.

type Link struct {
	Next string `json:"next"`
}

Link model used for paged records.

Jump to

Keyboard shortcuts

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