db

package
v0.0.0-...-4688aa9 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CardByMTGJsonID

func CardByMTGJsonID(dbh *Handle, id string) (*mtgjson.Card, error)

CardByMTGJsonID returns the first card found with the given mtgjson.com id

func CardByName

func CardByName(dbh *Handle, name string) (*mtgjson.Card, error)

CardByName returns the most recent version of a card with the exact given name

func SaveCards

func SaveCards(db *Handle, sets map[string]mtgjson.Set) error

SaveCards saves all given cards to the db

func SchemaMigrations

func SchemaMigrations() []*gomigrate.Migration

SchemaMigrations gives each caller a new copy of the migrations. This is mostly useful to allow unit tests to run in parallel.

func SearchCards

func SearchCards(db *Handle, columns []string, values [][]string) ([]mtgjson.Card, error)

SearchCards implements advanced searching of the card db

Types

type Handle

type Handle struct {
	// contains filtered or unexported fields
}

Handle controls access to the database and makes sure only one operation is in process at a time.

func NewDBHandle

func NewDBHandle(dbPath string, verbose bool, logger logrus.FieldLogger) *Handle

NewDBHandle creates a new DBHandle

dbPath: the path to the database to use.
verbose: when true database accesses are logged to stdout

func NewMemoryDBHandle

func NewMemoryDBHandle(verbose bool, logger logrus.FieldLogger, loadFixtures bool) *Handle

NewMemoryDBHandle creates a new in memory database. Only used for testing. The name of the database is a random string so multiple tests can run in parallel with their own database.

func (*Handle) Migrate

func (d *Handle) Migrate(m []*gomigrate.Migration) error

Migrate uses the migrations at the given path to update the database.

Jump to

Keyboard shortcuts

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