Documentation ¶
Index ¶
- Variables
- type User
- type UserService
- func (us *UserService) Authenticate(email, password string) (*User, error)
- func (us *UserService) AutoMigrate() error
- func (us *UserService) ByEmail(email string) (*User, error)
- func (us *UserService) ByID(id uint) (*User, error)
- func (us *UserService) Close() error
- func (us *UserService) Create(user *User) error
- func (us *UserService) Delete(id uint) error
- func (us *UserService) DestructiveReset() error
- func (us *UserService) Update(user *User) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound is returned when a resource cannot be found in the database. ErrNotFound = errors.New("models: resource not found") // ErrInvalidID is returned when an invalid ID is provided to a method (e.g. Delete). ErrInvalidID = errors.New("models: ID must be > 0") ErrInvalidPassword = errors.New("models: incorrect password provided") )
Functions ¶
This section is empty.
Types ¶
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
func NewUserService ¶
func NewUserService(connectionInfo string) (*UserService, error)
func (*UserService) Authenticate ¶
func (us *UserService) Authenticate(email, password string) (*User, error)
Authenticate can be used to authenticate a user with the provided email address and password.
func (*UserService) AutoMigrate ¶
func (us *UserService) AutoMigrate() error
AutoMigrate will attempt to automatically migrate the Users table.
func (*UserService) ByEmail ¶
func (us *UserService) ByEmail(email string) (*User, error)
ByEmail will look up a user with the provided email address.
func (*UserService) ByID ¶
func (us *UserService) ByID(id uint) (*User, error)
ByID will look up a user with the provided id.
func (*UserService) Close ¶
func (us *UserService) Close() error
Close closes the UserService database connection.
func (*UserService) Create ¶
func (us *UserService) Create(user *User) error
Create creates the provided user and will backfill data (e.g. ID, CreatedAt, UpdatedAt, DeletedAt).
func (*UserService) Delete ¶
func (us *UserService) Delete(id uint) error
Delete will delete the user with the provided id.
func (*UserService) DestructiveReset ¶
func (us *UserService) DestructiveReset() error
DestructiveReset drops the User table and rebuilds it.
func (*UserService) Update ¶
func (us *UserService) Update(user *User) error
Update will update the provided user with all of the data in the provided user object.
Click to show internal directories.
Click to hide internal directories.