user

package
v0.0.0-...-9c0a888 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

type Repository interface {
	FindByEmail(email string) (*User, error)
	FindByID(id uint32) (*User, error)
	Register(user *User) (*User, error)
	DoesEmailExist(email string) bool
}

Repository is an interface to separate impl of different db func

func NewDatabaseRepo

func NewDatabaseRepo(db *gorm.DB) Repository

NewDatabaseRepo adds a layer of abstraction so that everything in the interface Repository can be accessed only via the instance of this function

type Service

type Service interface {
	Register(user *User) (*User, error)
	Login(email, password string) (*User, error)
	GetUserByID(id uint32) (*User, error)
	GetUserByEmail(email string) (*User, error)
	GetRepo() Repository
}

Service interface for abstraction over higher functions

func NewService

func NewService(r Repository) Service

NewService function to get new instance of server

type User

type User struct {
	gorm.Model
	Name     string `json:"name" gorm:"not null"`
	Email    string `json:"email" gorm:"UNIQUE, not null"`
	Password string `json:"password" gorm:"not null"`
}

User model which stores user information

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL