models

package
v0.0.0-...-2cb1283 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Db *gorm.DB

Db - defines a sesion of the database

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

CheckPasswordHash hash compares raw password with it's hashed values

func CloseDB

func CloseDB()

CloseDB - close the conection to the database

func GetTechnicianIDByEmail

func GetTechnicianIDByEmail(email string) (uint, error)

GetTechnicianIDByEmail check if a user exists in database by given email

func GetUserIDByEmail

func GetUserIDByEmail(email string) (uint, error)

GetUserIDByEmail check if a user exists in database by given email

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes given password

func InitDB

func InitDB(cnf DBConfigParams) error

InitDB - creates a season to the database

func MigrateAll

func MigrateAll()

MigrateAll - execute a migration in all schemas implemented in the model package

Types

type DBConfigParams

type DBConfigParams struct {
	// contains filtered or unexported fields
}

DBConfigParams - contains the user configuration to start the database

type SchemaOrder

type SchemaOrder struct {
	gorm.Model
	Description  string `gorm:"type:text;default:''"`
	Status       string `gorm:"type:enum('Created','Pending','Done');not null"`
	Calification int    `gorm:"type:tinyint;default:1"`
	Feedback     string `gorm:"type:tinytext;default:''"`
	User         SchemaUser
	Technician   SchemaTechnician
	Tv           SchemaTelevision
}

SchemaOrder - Defines an Order model of the database

func (*SchemaOrder) Create

func (order *SchemaOrder) Create(user SchemaUser, tv SchemaTelevision) error

Create - creates a new Television regist

type SchemaTechnician

type SchemaTechnician struct {
	gorm.Model
	Email     string `gorm:"type:varchar(100);unique_index;not null;primary_key"`
	Password  string `gorm:"type:varchar(100);unique_index"`
	FirstName string `gorm:"type:varchar(50);not null"`
	LastName  string `gorm:"type:varchar(50);not null"`
}

SchemaTechnician - defines a Technician model of the database

func (*SchemaTechnician) All

func (technician *SchemaTechnician) All() ([]*SchemaTechnician, error)

All - return all the televisions in the database

func (*SchemaTechnician) Authenticate

func (technician *SchemaTechnician) Authenticate() bool

Authenticate - search the user and compare the given password

func (*SchemaTechnician) Create

func (technician *SchemaTechnician) Create() error

Create - creates a new Television regist

type SchemaTelevision

type SchemaTelevision struct {
	gorm.Model
	ModelTV string `gorm:"type:varchar(50);not null"`
	Brand   string `gorm:"type:varchar(50);not null"`
}

SchemaTelevision - defines a Television model of the database

func (*SchemaTelevision) All

func (tv *SchemaTelevision) All() ([]*SchemaTelevision, error)

All - return all the televisions in the database

func (*SchemaTelevision) Create

func (tv *SchemaTelevision) Create() error

Create - creates a new Television regist

type SchemaUser

type SchemaUser struct {
	gorm.Model
	Email     string `gorm:"type:varchar(100);unique_index;not null;primary_key"`
	Password  string `gorm:"type:varchar(100);not null"`
	FirstName string `gorm:"type:varchar(50);not null"`
	LastName  string `gorm:"type:varchar(50);not null"`
}

SchemaUser - defines a User model of the database

func (*SchemaUser) Authenticate

func (user *SchemaUser) Authenticate() bool

Authenticate - search the user and compare the given password

func (*SchemaUser) Create

func (user *SchemaUser) Create() error

Create - creates a new Television regist

Jump to

Keyboard shortcuts

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