user

package
v0.0.0-...-f5e312f Latest Latest
Warning

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

Go to latest
Published: Oct 25, 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 PrivateUser

type PrivateUser struct {
	ID          int64  `json:"id"`
	UserName    string `json:"username"`
	Email       string `json:"email"`
	DateCreated string `json:"date_created"`
	DateUpdated string `json:"date_updated"`
}

PrivateUser contains all info about the user only avaibale to the owner user

type PublicUser

type PublicUser struct {
	ID       int64  `json:"id"`
	UserName string `json:"username"`
}

PublicUser contains all the info about a user excluding some private/sensitive info

type User

type User struct {
	ID          int64  `json:"id"`
	UserName    string `json:"username"`
	Email       string `json:"email"`
	Password    string `json:"password"`
	DateCreated string `json:"date_created"`
	DateUpdated string `json:"date_updated"`
}

User defines the core User of the app

func (*User) Delete

func (u *User) Delete() *resterror.RestError

Delete used to delete a user from the db

func (*User) Get

func (u *User) Get() *resterror.RestError

Get : retrives a user with the id / returns a [RestError]

func (*User) GetUserByEmail

func (u *User) GetUserByEmail() (*User, *resterror.RestError)

GetUserByEmail returns a user with the given email address

func (*User) Marshaller

func (u *User) Marshaller(isPrivate bool) interface{}

Marshaller will marshall the incoming user and convert it into private/public user

func (*User) Save

func (u *User) Save() *resterror.RestError

Save used to save a user into the database

func (*User) Update

func (u *User) Update() *resterror.RestError

Update updates the user with the given info

func (*User) Validate

func (u *User) Validate() *resterror.RestError

Validate is used to validate wheather the current user provided is a valid user or not

func (*User) ValidateEmail

func (u *User) ValidateEmail() *resterror.RestError

ValidateEmail will trim and check if the email is valid or not and returns a rest error if invalid

Jump to

Keyboard shortcuts

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