models

package
v0.0.0-...-cf05431 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserAlreadyExists = errors.New("user already exists")
	ErrUserNotFound      = errors.New("user not found")
)

Functions

This section is empty.

Types

type User

type User struct {
	ID        uint      `json:"id"`
	Username  string    `json:"username"`
	Email     string    `json:"email"`
	Biography string    `json:"biography"`
	Password  string    `json:"-"`
	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`
}

A User is a struct that has an ID, Username, Email, Biography, Password, CreatedAt, and UpdatedAt. @property {uint} ID - The user's ID. @property {string} Username - The username of the user. @property {string} Email - The email address of the user. @property {string} Biography - A short description of the user. @property {string} Password - This is the password of the user. We don't want to return this to the client, so we add the `-` tag to the property. @property CreatedAt - The time the user was created @property UpdatedAt - The time the user was last updated.

type UserService

type UserService interface {
	CreateNewUser(user *User) error
	IsExistingUser(username, email string) bool
	GetUser(user *User) error
	GetUserById(user *User) error

	Close() error
	// contains filtered or unexported methods
}

`UserService` is an interface that has a method called `CreateNewUser` that takes a pointer to a `User` and returns an error. @property {error} CreateNewUser - This is the method that will be used to create a new user.

func NewUserService

func NewUserService(psqlInfo string) (UserService, error)

NewUserService create a new instance of UserService returns the newly created UserService instance or ErrInternalServerError if other error is encountered.

Jump to

Keyboard shortcuts

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