Documentation ¶
Index ¶
- Constants
- type DB
- type Store
- func (s *Store) DeleteUser(ctx context.Context, id string) error
- func (s *Store) FindUsers(ctx context.Context, filters []model.Filter, offset, limit int64) ([]*model.User, error)
- func (s *Store) GetUser(ctx context.Context, id string) (*model.User, error)
- func (s *Store) GetUserByEmail(ctx context.Context, email string) (*model.User, error)
- func (s *Store) InsertUser(ctx context.Context, u *model.User) (*model.User, error)
- func (s *Store) UpdateUser(ctx context.Context, u *model.User) (*model.User, error)
Constants ¶
View Source
const ( // ErrInvalidEmail is returned when the email is not a valid address or is empty. ErrInvalidEmail = errors.Error("invalid_email: email is invalid") // ErrEmailAlreadyUsed is returned when the email address is already used via another user. ErrEmailAlreadyUsed = errors.Error("email_already_used: email is already in use") // ErrEmptyNickname is returned when the nickname is empty. ErrEmptyNickname = errors.Error("empty_nickname: nickname is empty") // ErrNicknameAlreadyUsed is returned when the nickname is already used via another user. ErrNicknameAlreadyUsed = errors.Error("nickname_already_used: nickname is already in use") // ErrEmptyPassword is returned when the password is empty. ErrEmptyPassword = errors.Error("empty_password: password is empty") // ErrEmptyCountry is returned when the country is empty. ErrEmptyCountry = errors.Error("empty_country: password is empty") // ErrInvalidID si returned when the ID is not a valid UUID or is empty. ErrInvalidID = errors.Error("invalid_id: id is invalid") // ErrUserNotUpdated is returned when a record can't be found to update. ErrUserNotUpdated = errors.Error("user_not_updated: user record wasn't updated") // ErrUserNotDeleted is returned when a record can't be found to delete. ErrUserNotDeleted = errors.Error("user_not_deleted: user record wasn't deleted") // ErrInvalidFilters is returned when the filters for finding a user are not valid. ErrInvalidFilters = errors.Error("invalid_filters: filters invalid for finding user") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB interface { NamedQueryContext(ctx context.Context, query string, arg interface{}) (*sqlx.Rows, error) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error) }
DB represents a type for interfacing with a postgres database.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides functionality for working with a postgres database.
func (*Store) DeleteUser ¶
DeleteUser will delete an existing user via their ID.
func (*Store) FindUsers ¶
func (s *Store) FindUsers(ctx context.Context, filters []model.Filter, offset, limit int64) ([]*model.User, error)
FindUsers will retrieve a list of users based on matching all of the the provided filters and using pagination if limit is gt 0 Note: depending on the actual use cases for such functionality I would probably take the route of using elasticsearch and opening up the flexibility of having a search type function.
func (*Store) GetUserByEmail ¶
GetUserByEmail will retrieve an existing user via their email address.
func (*Store) InsertUser ¶
InsertUser will add a new unique user to the database using the provided data.
Click to show internal directories.
Click to hide internal directories.