db

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UnknownClassTable is the name of the table that will hold all the unknown class values provided by Alexa
	UnknownClassTable = "unknown_classes"
	// UnknownItemTable is the name of the table that will hold the unknown item name values passed by Alexa
	UnknownItemTable = "unknown_items"
)

Variables

This section is empty.

Functions

func FindEngramHashes added in v0.3.0

func FindEngramHashes() (map[uint]bool, error)

FindEngramHashes is responsible for querying all of the item_hash values that represent engrams and returning them in a map for quick lookup later.

func GetItemNameFromHash added in v0.2.0

func GetItemNameFromHash(itemHash string) (string, error)

GetItemNameFromHash is in charge of querying the database and reading the item name value for the given item hash.

func GetRandomJoke added in v1.0.0

func GetRandomJoke() (string, string, error)

GetRandomJoke will return a setup, punchline, and possibly an error for a random Destiny related joke.

func InitDatabase added in v0.2.0

func InitDatabase() error

InitDatabase is in charge of preparing any Statements that will be commonly used as well as setting up the database connection pool.

func InitEnv added in v1.1.0

func InitEnv(url string)

InitEnv provides a package level initialization point for any work that is environment specific

func InsertUnknownValueIntoTable added in v0.2.0

func InsertUnknownValueIntoTable(value, tableName string)

InsertUnknownValueIntoTable is a helper method for inserting a value into the specified table. This is used when a value for a slot type is not usable. For example when a class name for a character is not a valid Destiny class name.

func LoadItemMetadata added in v0.3.0

func LoadItemMetadata() (*sql.Rows, error)

LoadItemMetadata will load all rows from the database for all items loaded out of the manifest. Only the required columns will be loaded into memory that need to be used later for common operations.

func SaveLoadout added in v1.2.0

func SaveLoadout(loadoutJSON []byte, membershipID, name string) error

SaveLoadout is responsible for persisting the provided serialized loadout to the database.

func SelectLoadout added in v1.2.0

func SelectLoadout(membershipID, name string) (string, error)

SelectLoadout is responsible for querying the database for a loadout with the provided membership ID and loadout name. The return value is the JSON string for the loadout requested.

func SelectLoadouts added in v1.8.1

func SelectLoadouts(membershipID string) ([]string, error)

SelectLoadouts is responsible for querying the database for a loadout with the provided membership ID and loadout name. The return value is the JSON string for the loadout requested.

func UpdateLoadout added in v1.2.0

func UpdateLoadout(loadoutJSON []byte, membershipID, name string) error

UpdateLoadout can be used to update an existing loadout by membership ID and loadout name this should be used after confirming with the user that they want to update a loadout with a spepcific name.

Types

type LookupDB added in v0.2.0

type LookupDB struct {
	Database                *sql.DB
	HashFromNameStmt        *sql.Stmt
	NameFromHashStmt        *sql.Stmt
	EngramHashStmt          *sql.Stmt
	ItemMetadataStmt        *sql.Stmt
	RandomJokeStmt          *sql.Stmt
	InsertLoadoutStmt       *sql.Stmt
	UpdateLoadoutStmt       *sql.Stmt
	SelectLoadoutStmt       *sql.Stmt
	SelectLoadoutByNameStmt *sql.Stmt
}

LookupDB is a wrapper around the database connection pool that stores the commonly used queries as prepared statements.

func GetDBConnection

func GetDBConnection() (*LookupDB, error)

GetDBConnection is a helper for getting a connection to the DB based on environment variables or some other method.

Jump to

Keyboard shortcuts

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