Documentation ¶
Index ¶
- Constants
- type DbMaker
- type Store
- func (s *Store) AddUser(m models.UserModel, t string) error
- func (s *Store) CheckUser(i string, t string) bool
- func (s *Store) Close() error
- func (s *Store) CreateTable(n string, m interface{}) error
- func (s *Store) DeleteUser(i string, t string) error
- func (s *Store) GetLeaderboard(t string) ([]models.UserModel, error)
- func (s *Store) GetUser(i string, t string) (models.UserModel, error)
- func (s *Store) ListUsers(t string) ([]models.UserModel, error)
- func (s *Store) Ping() error
- func (s *Store) UpdateUser(m models.UserModel, t string) error
Constants ¶
View Source
const (
UsersTable = "users"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DbMaker ¶
func MakePostgresDb ¶
func MakePostgresDb() DbMaker
Creates a pointer to a gorm db.
This uses environmental variables for the dsn.
A connection is then opened, checked for errors and returned.
Keys for environmental variables:
- DB_ADDR : stores the address (IP)
- DB_PORT : stores the port
- DB_USER : stores the username
- DB_PASS : stores the password
- DB_NAME : stores the database name
func MakeSQLiteDb ¶
func MakeSQLiteDb() DbMaker
Creates a pointer to a gorm db.
This uses an environmental variable for the path to the sqlite db.
Keys for environmental variables:
- SQLITE_DB : file name of sqlite db.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Storers a *gorm.DB and its mutex.
func (*Store) CreateTable ¶
func (*Store) DeleteUser ¶
Deletes the given user id in the given table.
func (*Store) GetLeaderboard ¶
Gets the leaderboard, the, at max, top 10 users in the table by elo.
Click to show internal directories.
Click to hide internal directories.