db

package
v0.0.0-...-23f2fb9 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Error = ErrorStruct{}

Functions

func CreateObject

func CreateObject(r interface{}) error

CreateObject creates a new Object

func DeleteObject

func DeleteObject(r interface{}) error

DeleteObject deletes an Object

func GetDB

func GetDB() *gorm.DB

GetDB returns the db object

func InitDB

func InitDB()

InitDB initilizes the db object and the tables

func UpdateObject

func UpdateObject(r interface{}) error

UpdateObject updates an Object

Types

type ErrorStruct

type ErrorStruct struct{}

func (ErrorStruct) ErrCreate

func (e ErrorStruct) ErrCreate(err error, what string) error

ErrCreate is an function that checks if there is an error creating an object in the db

func (ErrorStruct) ErrDelete

func (e ErrorStruct) ErrDelete(err error, what string) error

ErrDelete is an function that checks if there is an error deleting an object from the db

func (ErrorStruct) ErrIsEmpty

func (e ErrorStruct) ErrIsEmpty(err error, whats string) error

ErrIsEmpty is an function that checks if the return from a search query of db is empty

func (ErrorStruct) ErrNotFound

func (e ErrorStruct) ErrNotFound(err error, what string) error

ErrNotFound is an function that checks if an object is not found in the db

func (ErrorStruct) ErrUpdate

func (e ErrorStruct) ErrUpdate(err error, what string) error

ErrUpdate is an function that checks if there is an error updating an object in the db

type Token

type Token struct {
	UserID uint
	jwt.StandardClaims
}

Token is the JWT claims struct

type User

type User struct {
	ID       uint   `json:"id"`
	Username string `json:"username"`
	Password string `json:"password"`
	Token    string `json:"token"`
}

User struct is a struct to rep user account

func GetUser

func GetUser(u uint) *User

GetUser function

func GetUserByUsername

func GetUserByUsername(username string) *User

GetUserByUsername function

Jump to

Keyboard shortcuts

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