Documentation ¶
Index ¶
- Variables
- func DeleteFluid(id string) error
- func DeleteFoodDiary(id string) error
- func DeleteFoodInventory(id string) error
- func DeleteMeasurement(id string) error
- func GetDB() *gorm.DB
- func Init() (*gorm.DB, error)
- func InitData() error
- func Migrate() error
- func PasswordHash(password string) (string, error)
- func SaveOne(data interface{}) error
- func StoreImages(urls *[]string, userID uint, FoodInventoryID *uint) error
- type Fluid
- type FluidSearch
- type FoodDiary
- type FoodInventory
- type FoodInventoryImg
- type MealType
- type Measurement
- type QuantityUnit
- type Upload
- type User
- type UserSetting
Constants ¶
This section is empty.
Variables ¶
View Source
var DB *gorm.DB
DB holds the the database connection. I know, it's global variable. I think in this case might be justified ¯\_(ツ)_/¯
Functions ¶
func DeleteFluid ¶
func DeleteFoodDiary ¶
func DeleteFoodInventory ¶
func DeleteMeasurement ¶
func PasswordHash ¶
Types ¶
type Fluid ¶
type Fluid struct { gorm.Model `binding:"-"` Type string `json:"type" binding:"required"` Date time.Time `json:"date" binding:"required"` Value float32 `gorm:"type:FLOAT" json:"value,string" binding:"required"` UserID uint `binding:"-"` }
func FindFluids ¶
func FindFluids(f *FluidSearch) ([]Fluid, error)
func FindOneFluid ¶
type FoodDiary ¶
type FoodDiary struct { gorm.Model MealTypeID string // Breakfast, Lunch, Dinner, Snacks, Water Quantity float32 `gorm:"type:FLOAT"` Date time.Time QuantityUnitID uint Comments string UserID uint FoodInventoryID uint FoodInventory FoodInventory }
func FindManyFoodDiary ¶
func FindOneFoodDiary ¶
type FoodInventory ¶
type FoodInventory struct { gorm.Model OffCode string ProductName string Description string Favourite bool UserID uint FoodDiary []FoodDiary FoodInventoryImg []FoodInventoryImg // Important values to save so we're not always querying OFF Calories float32 FatTotal float32 FatSaturated float32 FatPolyunsaturated float32 FatMonounsaturated float32 FatTrans float32 FatCholesterol float32 Sodium float32 Potassium float32 Carbs float32 Fibers float32 Sugars float32 Proteins float32 }
func FindManyFoodInventory ¶
func FindManyFoodInventory(UserID uint) ([]FoodInventory, error)
func FindOneFoodInventory ¶
func FindOneFoodInventory(id string) (FoodInventory, error)
type FoodInventoryImg ¶
type Measurement ¶
type Measurement struct { gorm.Model `binding:"-"` Type string `json:"type" binding:"required"` Date time.Time `json:"date" binding:"required"` Value float32 `gorm:"type:FLOAT" json:"value,string" binding:"required"` UserID uint `binding:"-"` }
func FindManyMeasurement ¶
func FindManyMeasurement(UserID uint) ([]Measurement, error)
func FindOneMeasurement ¶
func FindOneMeasurement(UserID string) (Measurement, error)
type QuantityUnit ¶
type User ¶
type User struct { gorm.Model Username string Password string IsAdmin bool UserSettingID uint UserSetting UserSetting FoodDiaries []FoodDiary FoodInventory []FoodInventory Measurement []Measurement Upload []Upload }
func FindOneUser ¶
FindOneUser search in the users table for a user.
func (*User) CheckPassword ¶
type UserSetting ¶
type UserSetting struct { gorm.Model Country string // Used for searching in OpenFoodFacts Timezone string Avatar string Language string Theme string FullName string Email string Birthday time.Time UseMetric bool Sex string Height float32 BodyFat string ActivityLevel string UserID uint }
func FindOneSetting ¶
func FindOneSetting(UserID int) (UserSetting, error)
FindOneUser search in the users table for a user.
Click to show internal directories.
Click to hide internal directories.