Documentation ¶
Index ¶
Constants ¶
View Source
const ( ErrUserIDRequired modelError = "model: user ID is required" ErrTitleRequired modelError = "model: title is required" )
View Source
const ( // ErrNotFound is returned when a resource cannot be found ErrNotFound modelError = "model: resource not found" // ErrIDInvalid is returned when an invalid ID is provided to a method like Delete ErrIDInvalid modelError = "model: ID provided was invalid" // ErrPasswordIncorrect is returned when an invalid password is provided ErrPasswordIncorrect modelError = "model: incorrect password provided" // ErrPasswordTooShort is returned when the password provided does not meet the 8 character minimum ErrPasswordTooShort modelError = "model: passwords must be at least 8 characters long" // ErrPasswordRequired is returned when a create is attempted without a user password provided ErrPasswordRequired modelError = "model: password is required" // ErrEmailRequired is returned when an email address is not provided when creating a user ErrEmailRequired modelError = "model: email address is required" // ErrEmailInvalid is returned when an email address provided does not match our regex ErrEmailInvalid modelError = "model: email address is not valid" // ErrEmailTaken is returned when an update or create is attempted with an email address that is already in use ErrEmailTaken modelError = "model: email address is already taken" // ErrRememberRequired is returned when a create or update is attempted without a user remember token hash ErrRememberRequired modelError = "model: remember token is required" // ErrRememberTooShort is returned when a token does not meet the 32 byte minimum ErrRememberTooShort modelError = "model: remember token must be at least 32 bytes" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Gallery ¶
type Gallery struct { gorm.Model UserID uint `gorm:"not_null;index"` Title string `gorm:"not_null"` }
Gallery contains images to view
type GalleryDB ¶
type GalleryDB interface { ByID(id uint) (*Gallery, error) Create(gallery *Gallery) error Update(gallery *Gallery) error Delete(id uint) error }
GalleryDB is the DB connection for galleries
type GalleryService ¶
type GalleryService interface { GalleryDB }
GalleryService provides an interface to the Gallery model
func NewGalleryService ¶
func NewGalleryService(db *gorm.DB) GalleryService
NewGalleryService instantiates a new GalleryService
type Services ¶
type Services struct { Gallery GalleryService User UserService // contains filtered or unexported fields }
Services to DB wrappers
func NewServices ¶
NewServices instatiates all the available services with one DB connection
func (*Services) AutoMigrate ¶
AutoMigrate will attempt to automatically migrate all the tables
func (*Services) DestructiveReset ¶
DestructiveReset drops all tables and rebuilds them
type User ¶
type User struct { gorm.Model Name string Email string `gorm:"not null;unique_index"` Password string `gorm:"-"` PasswordHash string `gorm:"not null"` Remember string `gorm:"-"` RememberHash string `gorm:"not null;unique_index"` }
User represents our customers
type UserDB ¶
type UserDB interface { ByID(id uint) (*User, error) ByEmail(email string) (*User, error) ByRemember(token string) (*User, error) // methods for altering users Create(user *User) error Update(user *User) error Delete(id uint) error }
UserDB is an interface to interact with the users db
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
NewUserService instantiates a new service with the provided connection information
Click to show internal directories.
Click to hide internal directories.