user

package
v0.0.0-...-1564ccb Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteUser

func DeleteUser(userID string, w http.ResponseWriter, r *http.Request)

DeleteUser deletes an user from database

func GetUser

func GetUser(userID string, w http.ResponseWriter, r *http.Request)

GetUser will return a single user by its ID

func GetUserGadget

func GetUserGadget(userID string, w http.ResponseWriter, r *http.Request)

GetUserGadget a single gadget of this user in the database

func GetUserGadgets

func GetUserGadgets(userID string, w http.ResponseWriter, r *http.Request)

GetUserGadgets returns a list of user gadget in the database

func RegisterUserGadget

func RegisterUserGadget(userID string, w http.ResponseWriter, r *http.Request)

RegisterUserGadget creates an user gadget row in the database

func Signin

func Signin(w http.ResponseWriter, r *http.Request)

Signin is used to created users get access to the system

func Signout

func Signout(w http.ResponseWriter, r *http.Request)

Signout is used to logout users, invalidating its JWT token

func Signup

func Signup(w http.ResponseWriter, r *http.Request)

Signup is used to register new users

func UnregisterUserGadget

func UnregisterUserGadget(userID string, w http.ResponseWriter, r *http.Request)

UnregisterUserGadget creates an user gadget row in the database

func UpdateUser

func UpdateUser(userID string, w http.ResponseWriter, r *http.Request)

UpdateUser update user's detail in the postgres db

func UpdateUserGadget

func UpdateUserGadget(userID string, w http.ResponseWriter, r *http.Request)

UpdateUserGadget updates gadget's detail in the postgres db

Types

type User

type User struct {
	ID       int64  `json:"user_id"`
	Username string `json:"username"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

func New

func New() *User

New returns an empty user

func (*User) Create

func (u *User) Create() error

Create inserts the user in the database

func (*User) Delete

func (u *User) Delete() error

Delete deletes the user record from the database

func (*User) Gadgets

func (u *User) Gadgets() *gadget.Gadgets

Gadgets returns a list of user's gadgets

func (*User) Update

func (u *User) Update() error

Update updates the user record in the database

type Users

type Users struct{}

Users is the entity used for controlling interactions with many users in the database

func NewUsers

func NewUsers() *Users

NewUsers returns an Users controller

func (*Users) All

func (us *Users) All() ([]*User, error)

All returns all the users registered in the database

func (*Users) Delete

func (us *Users) Delete(ID int64) error

Delete deletes an user based on its ID

func (*Users) Get

func (us *Users) Get(id int64) (*User, error)

Get returns a single user according to its ID

func (*Users) Search

func (us *Users) Search(f string) (*User, error)

Search returns a single user according to important unique attr

func (*Users) Where

func (us *Users) Where(exp string) ([]*User, error)

Where return many users according to a map of attrs

Jump to

Keyboard shortcuts

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