users

package
v0.0.0-...-08310c7 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//DB_NAME is the db name
	DB_NAME = "mydb"
	//USERS_COLLECTION_NAME is the name for the users collection
	USERS_COLLECTION_NAME = "users"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PublicUser

type PublicUser struct {
	ID          string `json:"id"`
	FirstName   string `json:"first_name"`
	LastName    string `json:"last_name"`
	Email       string `json:"email"`
	DateCreated string `json:"date_created"`
	Status      string `json:"status"`
}

type User

type User struct {
	ID          string `json:"id" bson:"_id,omitempty"`
	FirstName   string `json:"first_name" bson:"first_name"`
	LastName    string `json:"last_name" bson:"last_name"`
	Email       string `json:"email"`
	DateCreated string `json:"date_created" bson:"date_created"`
	Status      string `json:"status"`
	Password    string `json:"password"`
}

User is the domain

func (*User) Delete

func (user *User) Delete() api_errors.RestErr

Delete delete the document from the collection by the userID

func (*User) FindByEmail

func (user *User) FindByEmail() api_errors.RestErr

FindByEmail fill the &user with the data user if the filter founds one otherwise returns an RestErr

func (*User) FindByEmailAndPassword

func (user *User) FindByEmailAndPassword() api_errors.RestErr

FindByEmailAndPassword try to get a User by the email and password

func (*User) Get

func (user *User) Get() api_errors.RestErr

Get get the user by the ID given

func (*User) IsAvailableEmail

func (user *User) IsAvailableEmail() api_errors.RestErr

IsAvailableEmail returns an RestErr if the email already exist

func (*User) Marshal

func (user *User) Marshal() interface{}

func (*User) Save

func (user *User) Save() api_errors.RestErr

Save save a new user to the users collections

func (*User) Validate

func (user *User) Validate() api_errors.RestErr

Validate validates FirstName, LastName, Email and Password (only trimspace)

type UserLoginRequest

type UserLoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

Jump to

Keyboard shortcuts

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