database

package
v0.0.0-...-116427d Latest Latest
Warning

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

Go to latest
Published: May 20, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*sql.DB
	// contains filtered or unexported fields
}

DB represents the Askgod database

func Connect

func Connect(driver string, host string, username string, password string, database string, connections int, logger log15.Logger) (*DB, error)

Connect sets up the database connection and returns a DB struct

func (*DB) ClearFlags

func (db *DB) ClearFlags() error

ClearFlags wipes all flag entries from the database

func (*DB) ClearScores

func (db *DB) ClearScores() error

ClearScores wipes all score entries from the database

func (*DB) ClearTeams

func (db *DB) ClearTeams() error

ClearTeams wipes all team entries from the database

func (*DB) CreateFlag

func (db *DB) CreateFlag(flag api.AdminFlagPost) (int64, error)

CreateFlag adds a new flag to the database

func (*DB) CreateScore

func (db *DB) CreateScore(score api.AdminScorePost) (int64, error)

CreateScore adds a new score entry to the database

func (*DB) CreateTeam

func (db *DB) CreateTeam(team api.AdminTeamPost) (int64, error)

CreateTeam adds a new team to the database

func (*DB) DeleteFlag

func (db *DB) DeleteFlag(id int64) error

DeleteFlag deletes a single flag from the database

func (*DB) DeleteScore

func (db *DB) DeleteScore(id int64) error

DeleteScore deletes a single score entry from the database

func (*DB) DeleteTeam

func (db *DB) DeleteTeam(id int64) error

DeleteTeam deletes a single team from the database

func (*DB) GetConfig

func (db *DB) GetConfig() (*api.ConfigPut, error)

GetConfig retrieves the configuration

func (*DB) GetCurrentSchema

func (db *DB) GetCurrentSchema() (int, error)

GetCurrentSchema returns the current DB schema version

func (*DB) GetFlag

func (db *DB) GetFlag(id int64) (*api.AdminFlag, error)

GetFlag retrieves a single flag entry from the database

func (*DB) GetFlags

func (db *DB) GetFlags() ([]api.AdminFlag, error)

GetFlags retrieves all the flag entries from the database

func (*DB) GetScore

func (db *DB) GetScore(id int64) (*api.AdminScore, error)

GetScore retrieves a single score entry from the database

func (*DB) GetScoreboard

func (db *DB) GetScoreboard() ([]api.ScoreboardEntry, error)

GetScoreboard generates the current scoreboard

func (*DB) GetScores

func (db *DB) GetScores() ([]api.AdminScore, error)

GetScores retrieves all the score entries from the database

func (*DB) GetTeam

func (db *DB) GetTeam(id int64) (*api.AdminTeam, error)

GetTeam retrieves a single team entry from the database

func (*DB) GetTeamFlag

func (db *DB) GetTeamFlag(teamid int64, id int64) (*api.Flag, error)

GetTeamFlag retrieves a single score entry for the team

func (*DB) GetTeamFlags

func (db *DB) GetTeamFlags(teamid int64) ([]api.Flag, error)

GetTeamFlags retrieves all the score entries for the team

func (*DB) GetTeamForIP

func (db *DB) GetTeamForIP(ip net.IP) (*api.AdminTeam, error)

GetTeamForIP retrieves a single team entry for the provided IP

func (*DB) GetTeamPoints

func (db *DB) GetTeamPoints(teamid int64) (int64, error)

GetTeamPoints returns the current total for the team

func (*DB) GetTeams

func (db *DB) GetTeams() ([]api.AdminTeam, error)

GetTeams retrieves all the team entries from the database

func (*DB) GetTimeline

func (db *DB) GetTimeline() ([]api.TimelineEntry, error)

GetTimeline generates the current timeline

func (*DB) SubmitTeamFlag

func (db *DB) SubmitTeamFlag(teamid int64, flag api.FlagPost) (*api.Flag, *api.AdminFlag, error)

SubmitTeamFlag validates a submitted flag and adds it to the database

func (*DB) UpdateConfig

func (db *DB) UpdateConfig(config api.ConfigPut) error

UpdateConfig updates the configuration

func (*DB) UpdateFlag

func (db *DB) UpdateFlag(id int64, flag api.AdminFlagPut) error

UpdateFlag updates an existing flag

func (*DB) UpdateScore

func (db *DB) UpdateScore(id int64, score api.AdminScorePut) error

UpdateScore updates an existing score entry

func (*DB) UpdateTeam

func (db *DB) UpdateTeam(id int64, team api.AdminTeamPut) error

UpdateTeam updates an existing team

func (*DB) UpdateTeamFlag

func (db *DB) UpdateTeamFlag(teamid int64, id int64, flag api.FlagPut) error

UpdateTeamFlag updates a single score entry for the team

Jump to

Keyboard shortcuts

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