database

package
v0.1.0-pre Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DatabaseLocation string = "database.db"

Path to open the database from

View Source
const MigrationsLocation string = "migration.sql"

Variables

This section is empty.

Functions

func Connect

func Connect() *sqlx.DB

Returns a database connection. If the database has not been created it will create it and run migrations

Types

type Game

type Game struct {
	Id        int64     `db:"Id"`
	Name      string    `db:"Name"`
	CreatedAt time.Time `db:"CreatedAt"`
	Trainers  *[]Trainer
	Routes    *[]Route
}

func GetGame

func GetGame(db *sqlx.DB, name string) (*Game, bool)

func (*Game) GetRoute

func (g *Game) GetRoute(name string) (int64, bool)

func (*Game) IsDead

func (g *Game) IsDead() bool

func (*Game) String

func (g *Game) String() string

type Pokemon

type Pokemon struct {
	Id        int64  `db:"Id"`
	RouteId   int64  `db:"RouteId"`
	TrainerId int64  `db:"TrainerId"`
	Name      string `db:"Name"`
	Route     *Route
}

func GetPokemon

func GetPokemon(db *sqlx.DB, trainerId int64) []Pokemon

type Route

type Route struct {
	Id              int64  `db:"Id"`
	GameId          int64  `db:"GameId"`
	Name            string `db:"Name"`
	PokemonAreAlive bool   `db:"PokemonAreAlive"`
}

func GetRoute

func GetRoute(db *sqlx.DB, routeId int64) Route

func GetRoutes

func GetRoutes(db *sqlx.DB, gameId int64) []Route

type Trainer

type Trainer struct {
	Id      int64  `db:"Id"`
	GameId  int64  `db:"GameId"`
	Name    string `db:"Name"`
	Pokemon *[]Pokemon
}

func GetTrainers

func GetTrainers(db *sqlx.DB, gameId int64) []Trainer

Jump to

Keyboard shortcuts

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