model

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Rarity names
	RarityCommon     = "Common"
	RarityUncommon   = "Uncommon"
	RarityRare       = "Rare"
	RarityMythicRare = "Mythic Rare"
	RaritySpecial    = "Special"
	RarityLand       = "Land"
	RarityPromo      = "Promo"
	RarityBonus      = "Bonus"
	// Rarity aliases
	RarityAliasCommon     = "C"
	RarityAliasUncommon   = "U"
	RarityAliasRare       = "R"
	RarityAliasMythicRare = "M"
	RarityAliasSpecial    = "S"
	RarityAliasLand       = "L"
	RarityAliasPromo      = "P"
	RarityAliasBonus      = "B"
)

Variables

View Source
var (
	ErrInit         = errors.New("model.ErrInit")
	ErrNotFound     = errors.New("model.ErrNotFound")
	ErrBlankContext = errors.New("model.ErrBlankContext")
)
View Source
var (
	ErrInvalidState = errors.New("ErrInvalidState")
)

Functions

func Bulk

func Bulk(c *Context, q string, p ...[]interface{}) error

func Delete

func Delete(c *Context, q string, p ...interface{}) error

func Init

func Init() error

func Insert

func Insert(c *Context, q string, p ...interface{}) error

func NewAssetID

func NewAssetID(id string) string

func NewRarityID

func NewRarityID(n string) string

func NewSchema

func NewSchema() (graphql.Schema, error)

func NewSchemaConfig

func NewSchemaConfig() graphql.SchemaConfig

func Query

func Query(c *Context, q string, i Iterable, p ...interface{}) error

func QueryOne

func QueryOne(c *Context, q string, s Scannable, p ...interface{}) error

Types

type BulkIterator

type BulkIterator func() []interface{}

type Card

type Card struct {
	ID            string   `json:"id"`
	Name          string   `json:"name"`
	Types         []string `json:"types"`
	Costs         []string `json:"costs"`
	NumberCost    float32  `json:"numberCost"`
	IDExternal    string   `json:"idExternal"`
	OrderExternal string   `json:"orderExternal"`
	IDRarity      string   `json:"-"`
	Rarity        Rarity   `json:"rarity"`
	IDSet         string   `json:"-"`
	Set           Set      `json:"set"`
	IDAsset       string   `json:"idAsset"`
	Rules         []string `json:"rules"`
	Rate          float32  `json:"rate"`
	RateVotes     int      `json:"rateVotes"`
	Artist        string   `json:"artist"`
	Flavor        string   `json:"flavor"`
	Data          CardData `json:"data"`
	// contains filtered or unexported fields
}

func NewCard

func NewCard(set Set, name, qsExternal, types, qsAsset, computedCost string, rarity Rarity) *Card

func NewSetCards

func NewSetCards() []Card

func (*Card) AddCost

func (c *Card) AddCost(o string)

func (*Card) AddRule

func (c *Card) AddRule(r string)

func (Card) String

func (c Card) String() string

type CardData

type CardData map[string]string

func (CardData) String

func (d CardData) String() string

type Context

type Context struct {
	*util.Context
	*sql.DB
}

func CreateContext

func CreateContext(c *util.Context) (*Context, error)

func MakeContext

func MakeContext() (*Context, error)

func NewContext

func NewContext(c context.Context) (*Context, error)

type Iterable

type Iterable func(*Context, Iterator) error

type Iterator

type Iterator interface {
	Scanner
	Next() bool
}

type QueryResult

type QueryResult interface {
	LastInsertId() (int64, error)
	RowsAffected() (int64, error)
}

type Rarity

type Rarity struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Alias string `json:"alias"`
	// contains filtered or unexported fields
}

func NewRarity

func NewRarity(name, alias string) Rarity

func RarityByAlias

func RarityByAlias(a string) (*Rarity, error)

func (Rarity) String

func (r Rarity) String() string

type Scannable

type Scannable func(*Context, Scanner) error

type Scanner

type Scanner interface {
	Scan(...interface{}) error
}

type Set

type Set struct {
	ID    string   `json:"id"`
	Name  string   `json:"name"`
	Alias string   `json:"alias"`
	Asset SetAsset `json:"asset"`
	Cards []Card   `json:"cards"`
	// contains filtered or unexported fields
}

func CreateSet

func CreateSet(name string) *Set

func NewSet

func NewSet(name, alias string) *Set

func (*Set) AddCard

func (s *Set) AddCard(c Card)

func (Set) HasAsset

func (s Set) HasAsset(r Rarity) error

func (*Set) SetAsset

func (s *Set) SetAsset(r Rarity, id string)

func (Set) String

func (s Set) String() string

type SetAsset

type SetAsset map[string]string

func NewSetAsset

func NewSetAsset() SetAsset

func (*SetAsset) Scan

func (a *SetAsset) Scan(src interface{}) error

func (SetAsset) String

func (a SetAsset) String() string

func (SetAsset) Value

func (a SetAsset) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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