Documentation ¶
Overview ¶
Package db interacts with storing user attributes so they can be retrieved after the server restarts
Index ¶
- type Database
- type User
- type UserDao
- func (ud UserDao) Create(ctx context.Context, u User) error
- func (ud UserDao) Delete(ctx context.Context, u User) error
- func (ud UserDao) Read(ctx context.Context, u User) (User, error)
- func (ud UserDao) Setup(ctx context.Context) error
- func (ud UserDao) UpdatePassword(ctx context.Context, u User, newP string) error
- func (ud UserDao) UpdatePointsIncrement(ctx context.Context, usernames []string, f UserPointsIncrementFunc) error
- type UserDaoConfig
- type UserPointsIncrementFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database interface {
// contains filtered or unexported methods
}
Database contains methods to create, read, update, and delete data
func NewPostgresDatabase ¶
NewPostgresDatabase creates a postgres database from a databaseURL
type User ¶
type User struct { Username username Points int // contains filtered or unexported fields }
User contains information for each player
type UserDao ¶
type UserDao struct {
// contains filtered or unexported fields
}
UserDao contains CRUD operations for user-related information
func (UserDao) UpdatePassword ¶
UpdatePassword sets the password of a user
func (UserDao) UpdatePointsIncrement ¶
func (ud UserDao) UpdatePointsIncrement(ctx context.Context, usernames []string, f UserPointsIncrementFunc) error
UpdatePointsIncrement increments the points for multiple users
type UserDaoConfig ¶
type UserDaoConfig struct { // Debug is a flag that causes the socket to log the types non-ping/pong messages that are read/written DB Database // QueryPeriod is the amount of time that any database action can take before it should timeout QueryPeriod time.Duration }
UserDaoConfig contains commonly shared UserDao properties
func (UserDaoConfig) NewUserDao ¶
func (cfg UserDaoConfig) NewUserDao() (*UserDao, error)
NewUserDao creates a UserDao on the specified database
type UserPointsIncrementFunc ¶
UserPointsIncrementFunc is used to determine how much to increment the points for a username