Documentation
¶
Index ¶
- func NewRepository(canQuery bool) *repository.Repository
- func NewSessionRepository(canQuery bool) repository.SessionRepository
- func NewUserRepository(canQuery bool) repository.UserRepository
- type SessionRepository
- func (repo *SessionRepository) CreateSession(session *models.Session) (*models.Session, error)
- func (repo *SessionRepository) DeleteSession(session *models.Session) (*models.Session, error)
- func (repo *SessionRepository) SelectSession(session *models.Session) (*models.Session, error)
- func (repo *SessionRepository) UpdateSession(session *models.Session) (*models.Session, error)
- type UserRepository
- func (repo *UserRepository) CheckPassword(id int, pwd string) (bool, error)
- func (repo *UserRepository) CreateUser(user *models.User) (*models.User, error)
- func (repo *UserRepository) DeleteUser(user *models.User) (*models.User, error)
- func (repo *UserRepository) ReadUser(id uint) (*models.User, error)
- func (repo *UserRepository) ReadUserByEmail(email string) (*models.User, error)
- func (repo *UserRepository) UpdateUser(user *models.User) (*models.User, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRepository ¶
func NewRepository(canQuery bool) *repository.Repository
NewRepository returns a Repository which persists users in memory and accepts a parameter that can trigger read/write errors
func NewSessionRepository ¶
func NewSessionRepository(canQuery bool) repository.SessionRepository
NewSessionRepository returns pointer to repo along with the db
func NewUserRepository ¶
func NewUserRepository(canQuery bool) repository.UserRepository
NewUserRepository will return errors
Types ¶
type SessionRepository ¶
type SessionRepository struct {
// contains filtered or unexported fields
}
SessionRepository uses gorm.DB for querying the database
func (*SessionRepository) CreateSession ¶
CreateSession must take in Key, Data, and ExpiresAt as arguments.
func (*SessionRepository) DeleteSession ¶
DeleteSession deletes a session by Key
func (*SessionRepository) SelectSession ¶
SelectSession returns a session with matching key
func (*SessionRepository) UpdateSession ¶
UpdateSession updates only the Data field using Key as selector.
type UserRepository ¶
type UserRepository struct {
// contains filtered or unexported fields
}
UserRepository will return errors on queries if canQuery is false and only stores a small set of users in-memory that are indexed by their array index + 1
func (*UserRepository) CheckPassword ¶
func (repo *UserRepository) CheckPassword(id int, pwd string) (bool, error)
CheckPassword checks the input password is correct for the provided user id.
func (*UserRepository) CreateUser ¶
CreateUser adds a new User row to the Users table in array memory
func (*UserRepository) DeleteUser ¶
DeleteUser deletes a single user using their unique id
func (*UserRepository) ReadUser ¶
func (repo *UserRepository) ReadUser(id uint) (*models.User, error)
ReadUser finds a single user based on their unique id
func (*UserRepository) ReadUserByEmail ¶
func (repo *UserRepository) ReadUserByEmail(email string) (*models.User, error)
ReadUserByEmail finds a single user based on their unique email
func (*UserRepository) UpdateUser ¶
UpdateUser modifies an existing User in the database