Documentation
¶
Index ¶
Constants ¶
View Source
const ( ErrNotFound modelError = "models: resource not found" ErrIDInvalid privateError = "models: ID provided was invalid" ErrPasswordIncorrect modelError = "models: incorrect password" ErrRememberTokenTooShort privateError = "models: remember token must be at least 32 bytes" ErrRememberRequired privateError = "models: remember token required" ErrEmailRequired modelError = "Email address is required" ErrEmailInvalid modelError = "Email address is not valid" ErrEmailTaken modelError = "models: email address is already taken" ErrPasswordMinLength modelError = "Password must be 8 characters long" ErrPasswordRequired modelError = "Password is required" ErrUserIDRequired privateError = "models: user does not have id" ErrTitleRequired modelError = "A title is required for your gallery" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LocationDB ¶
type LocationService ¶
type LocationService interface { LocationDB }
func NewLocationService ¶
func NewLocationService(db *gorm.DB) LocationService
type Services ¶
type Services struct { User UserService Location LocationService // contains filtered or unexported fields }
func NewServices ¶
func (*Services) AutoMigrate ¶
Will attempt to automigrate all database tables
type User ¶
type User struct { gorm.Model Name string Email string `gorm:"not null;unique"` Password string `gorm:"-"` PasswordHash string `gorm:"not null"` Remember string `gorm:"-"` RememberHash string `gorm:"not null;unique"` }
User model which stores user name, email address, password hash, and remember hash in the PSQL database.
type UserDB ¶
type UserDB interface { // Methods for querying for single users ByID(id uint) (*User, error) ByEmail(email string) (*User, error) ByRemember(token string) (*User, error) // CRUD operations for user Create(user *User) error Update(user *User) error Delete(id uint) error GetAllUsers() ([]User, error) }
UserDB is used to interact with the database. As a general rule, any error but ErrNotFound should result in a 500 error
type UserService ¶
UserService is a set of methods used to manipulate and work with the user model
func NewUserService ¶
func NewUserService(db *gorm.DB) UserService
Click to show internal directories.
Click to hide internal directories.