Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DB *gorm.DB
Functions ¶
func CheckByUsername ¶
Try to log in the user with the username and password provided
func InitDatabase ¶
func InitDatabase()
func VerifyPassword ¶
Verify the password provided in the login request with the hashed password stored in the database
Types ¶
type ExerciseInformation ¶
type ExerciseInformation struct {
gorm.Model
ActivityName string // Name of the activity
Category string // Type of activity (e.g. Cardio, Resistance, Sports, etc.)
Resistance string // The vigour for the exercise (valid values include High, Medium or Low)
EnergyExpenditure float32 // Energy expenditure of the activity in kilocalories per unit body weight of the person
Users []*User `gorm:"many2many:user_exercises;"`
}
Struct to store the exercise information of the User
type HealthInformation ¶
type HealthInformation struct {
gorm.Model
UserID uint // User to which the health information belongs
Birthday time.Time // Birthday of the user
Weight uint8 // Weight of the user in kilograms
Height uint8 // Height of the user in centimeters
BMI float32 // Body Mass Index of the user calculated from the weight and height
ExerciseFrequency uint8 // Weekly exercise frequency of the user
}
Struct to store the health information of the User
type User ¶
type User struct {
gorm.Model
Name string `gorm:"not null"` // Full Name of the user
Username string `gorm:"not null;unique"` // Username of the user used for logging in to the application
Password string `gorm:"not null"` // Password of the user used for logging in to the application
Email string `gorm:"not null;unique"` // Email of the user, might be autofilled if user signs up using Google
PhoneNumber uint64 `gorm:"not null;unique"` // Phone number of the user
Gender string `gorm:"not null"` // Gender of the user values may include, male, female or other (BMI calculated as per male standards for other)
HealthInformation HealthInformation // Health information of the user
Exercises []*ExerciseInformation `gorm:"many2many:user_exercises;"` // Exercises performed by the user
}
Struct to store the basic information about the User One to One relation with the Health Information of the User One to Many relation with the Exercises performed by the User
func GetUserByID ¶
Find the user from the database with the provided ID
func (*User) BeforeSave ¶
Encrypt the password for the user before saving it to the database
Click to show internal directories.
Click to hide internal directories.