models

package
v0.0.0-...-d6f4c82 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type User

type User struct {
	ID        primitive.ObjectID `bson:"_id" json:"id,omitempty"`
	FirstName string             `json:"first_name"`
	LastName  string             `json:"last_name"`
	UserName  string             `json:"username"`
	Password  string             `json:"password"`
}

User represents a user of the system

func GetUserByUserName

func GetUserByUserName(username string) (*User, error)

GetUserByUserName returns the user record matching privided ID

type UserAuthentication

type UserAuthentication struct {
	UUID     string `json:"uuid" form:"-"`
	Username string `json:"username" form:"username"`
	Password string `json:"password" form:"password"`
}

UserAuthentication is used to authenticate the user and pass JWT to client

type UserCollection

type UserCollection struct {
	Users []User
}

UserCollection is a collection of user records

var Users UserCollection

Users is a package level variable acting as an in-memory user database

func (UserCollection) AllUsers

func (uc UserCollection) AllUsers() (*UserCollection, error)

AllUsers is a public method to return all the user details from the database

func (UserCollection) CreateUser

func (uc UserCollection) CreateUser(user *User) (*User, error)

CreateUser is a public method to create new user in the database

func (UserCollection) DeleteUserByID

func (uc UserCollection) DeleteUserByID(id string) (string, error)

DeleteUserByID is a public method to remove tge user record matching privided ID

func (UserCollection) GetUserByID

func (uc UserCollection) GetUserByID(id string) (*User, error)

GetUserByID returns the user record matching privided ID

Jump to

Keyboard shortcuts

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