Documentation ¶
Index ¶
- Variables
- func CheckPasswordHash(password, hash string) bool
- func CloseDB()
- func GetTechnicianIDByEmail(email string) (uint, error)
- func GetUserIDByEmail(email string) (uint, error)
- func HashPassword(password string) (string, error)
- func InitDB(cnf DBConfigParams) error
- func MigrateAll()
- type DBConfigParams
- type SchemaOrder
- type SchemaTechnician
- type SchemaTelevision
- type SchemaUser
Constants ¶
This section is empty.
Variables ¶
var Db *gorm.DB
Db - defines a sesion of the database
Functions ¶
func CheckPasswordHash ¶
CheckPasswordHash hash compares raw password with it's hashed values
func GetTechnicianIDByEmail ¶
GetTechnicianIDByEmail check if a user exists in database by given email
func GetUserIDByEmail ¶
GetUserIDByEmail check if a user exists in database by given email
func HashPassword ¶
HashPassword hashes given password
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