Documentation
¶
Overview ¶
Package postgres provides a PostgreSQL specific implementation of the services we provide.
Index ¶
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomString(n int) (string, error)
- func Open(connStr string) (*sql.DB, error)
- type AnnouncementService
- func (s *AnnouncementService) Create(message string) (err error)
- func (s *AnnouncementService) DeleteByID(id int) (err error)
- func (s *AnnouncementService) GetAllAnnouncements() (a []*models.Announcement, err error)
- func (s *AnnouncementService) GetByID(id int) (a *models.Announcement, err error)
- func (s *AnnouncementService) GetCurrent() (a *models.Announcement, err error)
- type ApplicationService
- func (s *ApplicationService) AddPointsToUser(uid int, points int) error
- func (s *ApplicationService) CheckIn(app *models.Application) (err error)
- func (s *ApplicationService) CreateOrUpdate(newApp *models.Application) (err error)
- func (s *ApplicationService) GetApplicationCount() int
- func (s *ApplicationService) GetByUserID(uid int) (*models.Application, error)
- type RSVPService
- type RaffleService
- type UserService
- func (s *UserService) GetByCode(code string) (u *models.User, err error)
- func (s *UserService) GetByEmail(email string) (u *models.User, err error)
- func (s *UserService) GetByID(id int) (u *models.User, err error)
- func (s *UserService) GetPasswordReset(email string) (string, error)
- func (s *UserService) GetUserCount() int
- func (s *UserService) Login(u *models.User) error
- func (s *UserService) ResetPassword(token string, password string) error
- func (s *UserService) Signup(u *models.User) (id int, code string, err error)
- func (s *UserService) TokenChangePassword(id int, uid int, password string) error
- func (s *UserService) Update(u *models.User) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomString ¶
GenerateRandomString returns a securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
Types ¶
type AnnouncementService ¶
AnnouncementService is a PostgreSQL implementation of models.announcement
func (*AnnouncementService) Create ¶
func (s *AnnouncementService) Create(message string) (err error)
Create creates an announcement and stores it in the DB
func (*AnnouncementService) DeleteByID ¶
func (s *AnnouncementService) DeleteByID(id int) (err error)
RemoveByID removes the announcement by id Note: removing by latest can cause racing call problems Should always remove by ID
func (*AnnouncementService) GetAllAnnouncements ¶
func (s *AnnouncementService) GetAllAnnouncements() (a []*models.Announcement, err error)
func (*AnnouncementService) GetByID ¶
func (s *AnnouncementService) GetByID(id int) (a *models.Announcement, err error)
GetByID returns an announcement with the given ID.
func (*AnnouncementService) GetCurrent ¶
func (s *AnnouncementService) GetCurrent() (a *models.Announcement, err error)
GetCurrent returns the most recent announcement (by timestamp)
type ApplicationService ¶
UserService is a PostgreSQL implementation of models.UserService
func (*ApplicationService) AddPointsToUser ¶
func (s *ApplicationService) AddPointsToUser(uid int, points int) error
add points to user
func (*ApplicationService) CheckIn ¶
func (s *ApplicationService) CheckIn(app *models.Application) (err error)
CheckIn attempts to check-in a user by switching boolean value of check-in from false to true.
func (*ApplicationService) CreateOrUpdate ¶
func (s *ApplicationService) CreateOrUpdate(newApp *models.Application) (err error)
CreateOrUpdate tries to make a new Application, if one already exists then it updates the existing one.
func (*ApplicationService) GetApplicationCount ¶
func (s *ApplicationService) GetApplicationCount() int
returns number of applications in the database
func (*ApplicationService) GetByUserID ¶
func (s *ApplicationService) GetByUserID(uid int) (*models.Application, error)
GetByUserID returns a single Application with the given user id.
type RSVPService ¶
RSVPService is a PostgreSQL implementation of models.RSVPService
func (*RSVPService) CreateOrUpdate ¶
func (s *RSVPService) CreateOrUpdate(r *models.RSVP) (err error)
CreateOrUpdate tries to make a new RSVP, unless one already exists then it updates the existing one.
func (*RSVPService) GetByUserID ¶
func (s *RSVPService) GetByUserID(uid int) (*models.RSVP, error)
GetByUserID returns a single RSVP with the given user id.
type RaffleService ¶
RaffleService is a PostgreSQL implementation of models.raffle
func (*RaffleService) ClaimRaffle ¶
func (s *RaffleService) ClaimRaffle(userId int, raffleId string) error
claim a raffle by inserting to raffle_hacker relation
type UserService ¶
UserService is a PostgreSQL implementation of models.UserService
func (*UserService) GetByCode ¶
func (s *UserService) GetByCode(code string) (u *models.User, err error)
GetByCode returns a single user with the given email confirmation code
func (*UserService) GetByEmail ¶
func (s *UserService) GetByEmail(email string) (u *models.User, err error)
GetByEmail returns a single user with the given email.
func (*UserService) GetByID ¶
func (s *UserService) GetByID(id int) (u *models.User, err error)
GetByID returns a single user with the given id.
func (*UserService) GetPasswordReset ¶
func (s *UserService) GetPasswordReset(email string) (string, error)
Creates the user's token for a password reset
func (*UserService) GetUserCount ¶
func (s *UserService) GetUserCount() int
Get number of users in the database
func (*UserService) Login ¶
func (s *UserService) Login(u *models.User) error
Login checks to see if a passed user's password matches the one recorded in the database. It expects to receive a user object with at least an email and a password. When Login fails it will return an error, otherwise it will return nil.
func (*UserService) ResetPassword ¶
func (s *UserService) ResetPassword(token string, password string) error
ResetPassword resets the user's password
func (*UserService) TokenChangePassword ¶
func (s *UserService) TokenChangePassword(id int, uid int, password string) error
TokenChangePassword changes password then deletes the token used