Documentation
¶
Index ¶
- Constants
- func ResetTables() error
- type DBHandler
- func (dbh *DBHandler) Connect() error
- func (dbh *DBHandler) ContainsPlayer(player models.Player) (bool, error)
- func (dbh *DBHandler) ContainsUser(user api.User) (bool, error)
- func (dbh *DBHandler) CreateGamesTable() error
- func (dbh *DBHandler) CreatePlayersTable() error
- func (dbh *DBHandler) CreateTables() error
- func (dbh *DBHandler) CreateUsersTable() error
- func (dbh *DBHandler) GetField(table, field, whereField string, whereVal interface{}) interface{}
- func (dbh *DBHandler) GetGameByID(id int) (*game_model.Game, error)
- func (dbh *DBHandler) GetGames() []*game_model.Game
- func (dbh *DBHandler) GetPlayerByID(id int) (*models.Player, error)
- func (dbh *DBHandler) GetUserByID(id int) (*api.User, error)
- func (dbh *DBHandler) InsertGame(game game_model.Game) error
- func (dbh *DBHandler) InsertPlayer(player models.Player) error
- func (dbh *DBHandler) InsertUser(user api.User) error
- func (dbh *DBHandler) NameExists(name string) (bool, error)
- func (dbh *DBHandler) Update(table, field string, value interface{}, whereField string, ...) error
Constants ¶
const ( //Driver is a name of db driver (requires go get github.com/mattn/go-sqlite3) Driver = "sqlite3" //Path is a path to file with database Path = "database/CandyWarGoDatabase.sqlite" )
Variables ¶
This section is empty.
Functions ¶
func ResetTables ¶
func ResetTables() error
Types ¶
type DBHandler ¶
DBHandler holds interfaces to interact with database
func NewDBHandler ¶
NewDBHandler returns pointer to the default ready to use DBHandler
func NewDBHandlerWithPath ¶
NewDBHandler returns pointer to the default ready to use DBHandler
func (*DBHandler) ContainsPlayer ¶
ContainsPlayer returns true if a player with the specified id is already registered
func (*DBHandler) ContainsUser ¶
ContainsUser returns true if a user with the specified id is already registered
func (*DBHandler) CreateGamesTable ¶
CreateGamesTable creates a table for games info, active player and his time mark for permission to start move
func (*DBHandler) CreatePlayersTable ¶
CreatePlayersTable creates a table of Players if one does not already exist
func (*DBHandler) CreateTables ¶
CreateTables is a shortcut to create all necessary tables
func (*DBHandler) CreateUsersTable ¶
CreateUsersTable creates a table of Users if one does not already exist
func (*DBHandler) GetField ¶
GetField returns value of field in given table in respect to to some parameter
func (*DBHandler) GetGameByID ¶
func (dbh *DBHandler) GetGameByID(id int) (*game_model.Game, error)
GetGameByID returns game.Game object from database with specified id
func (*DBHandler) GetGames ¶
func (dbh *DBHandler) GetGames() []*game_model.Game
GetGames returns array of all current games
func (*DBHandler) GetPlayerByID ¶
GetPlayerByID returns models.Player object from database with specified id
func (*DBHandler) GetUserByID ¶
GetUserByID returns api.User object from database with specified id
func (*DBHandler) InsertGame ¶
func (dbh *DBHandler) InsertGame(game game_model.Game) error
InsertGame adds a game to the Games table
func (*DBHandler) InsertPlayer ¶
InsertPlayer adds a user to the Users table
func (*DBHandler) InsertUser ¶
InsertUser adds a user to the Users table
func (*DBHandler) NameExists ¶
NameExists returns true if a user with the same name is already registered