models

package
v0.0.0-...-dee3174 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: MIT Imports: 3 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            int        `json:"id"`
	FirstName     string     `json:"first_name"`
	MiddleInitial string     `json:"middle_initial,omitempty"`
	LastName      string     `json:"last_name"`
	CreatedAt     *time.Time `json:"-"`
	UpdatedAt     *time.Time `json:"-"`
}

User represents a user of the system

type UserStorage

type UserStorage struct {
	Users []User
	Log   *zerolog.Logger
}

UserStorage ...

var UserDB UserStorage

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

func (*UserStorage) AddUser

func (us *UserStorage) AddUser(u User) (*User, error)

AddUser will add a user if it doesn't already exist or return an error

func (UserStorage) GetUserByID

func (us UserStorage) GetUserByID(id int) (*User, error)

GetUserByID returns the user record matching privided ID

func (UserStorage) GetUserByName

func (us UserStorage) GetUserByName(firstName string, lastName string) (*User, error)

GetUserByName will return the first user matching firstName and LastName This may not work in the real world since names are not unique

func (UserStorage) GetUsers

func (us UserStorage) GetUsers() []User

GetUsers returns the slice of all users

func (*UserStorage) UpdateUser

func (us *UserStorage) UpdateUser(u User) error

UpdateUser will overwrite current user record with new data

Jump to

Keyboard shortcuts

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