models

package
v0.0.0-...-f83a9ed Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RowExists

func RowExists(query string, args ...interface{}) (exists bool, err error)

Types

type Game

type Game struct {
	ID        string   `db:"id" json:"id"`
	StartAt   NullTime `db:"start_at" json:"start_at,omitempty"`
	HomeScore uint8    `db:"home_score" json:"home_score"`
	AwayScore uint8    `db:"away_score" json:"away_score"`
	HomeTeam  Team     `db:"home_team" json:"home_team"`
	AwayTeam  Team     `db:"away_team" json:"away_team"`
	HomeShots []*Shot  `json:"home_shots,omitempty"`
	AwayShots []*Shot  `json:"away_shots,omitempty"`
}

func FindGameByID

func FindGameByID(id string) (game Game, err error)

func (*Game) Create

func (game *Game) Create() (err error)

func (*Game) GetShots

func (game *Game) GetShots()

func (Game) IsValid

func (game Game) IsValid() (bool, error)

type GameResp

type GameResp struct {
	*Game
	HomeShots []PublicShot `json:"home_shots,omitempty"`
	AwayShots []PublicShot `json:"away_shots,omitempty"`
}

type LeanPlayer

type LeanPlayer struct {
	*Player
	Team omit `json:"team,omitempty"`
}

type NullTime

type NullTime struct {
	Time  time.Time `json:"time"`
	Valid bool      `json:"valid"`
}

type Player

type Player struct {
	ID           string `db:"id" json:"id"`
	Name         string `db:"full_name" json:"name,omitempty"`
	Active       bool   `db:"active" json:"active,omitempty"`
	JerseyNumber uint8  `db:"jersey_number" json:"jersey_number,omitempty,string"`
	Team         Team   `db:"team" json:"team,omitempty"`

	CreatedAt string `db:"created_at" json:"created_at,omitempty"`
	UpdatedAt string `db:"updated_at" json:"updated_at,omitempty"`
}

func FindPlayerByID

func FindPlayerByID(id string) (player Player, err error)

func (*Player) Create

func (player *Player) Create() (err error)

func (*Player) Update

func (player *Player) Update() (err error)

type PublicShot

type PublicShot struct {
	*Shot
	Game omit `json:"game,omitempty"`
	Team omit `json:"team,omitempty"`
}

type Shot

type Shot struct {
	ID        string `db:"id" json:"id"`
	Player    Player `db:"player" json:"player,omitempty"`
	Game      Game   `db:"game" json:"game,omitempty"`
	Team      Team   `db:"team" json:"team,omitempty"`
	PtValue   uint8  `db:"pt_value" json:"pt_value"`
	Made      bool   `db:"made" json:"made"`
	XAxis     uint64 `db:"x_axis" json:"x_axis"`
	YAxis     uint64 `db:"y_axis" json:"y_axis"`
	CreatedAt string `db:"created_at" json:"created_at"`
	UpdatedAt string `db:"updated_at" json:"updated_at"`
}

func (*Shot) Create

func (shot *Shot) Create() error

func (Shot) IsValid

func (shot Shot) IsValid() (playerIsOnTeam bool)

func (*Shot) Update

func (shot *Shot) Update() (err error)

type Team

type Team struct {
	ID      string    `db:"id" json:"id"`
	Name    string    `db:"name" json:"name,omitempty"`
	Players []*Player `json:"players,omitempty"`
	Games   []Game    `json:"games,omitempty"`
}

func FindTeamByID

func FindTeamByID(id string) (team Team, err error)

func (*Team) Create

func (team *Team) Create() error

func (*Team) GetPlayers

func (team *Team) GetPlayers()

func (Team) IsValid

func (team Team) IsValid() bool

func (Team) PlayerIsOnTeam

func (team Team) PlayerIsOnTeam(player Player) bool

func (*Team) Update

func (team *Team) Update() (err error)

type TeamResp

type TeamResp struct {
	*Team
	Players []LeanPlayer `json:"players,omitempty"`
}

for lean team json without redundant nested types

Jump to

Keyboard shortcuts

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