Documentation ¶
Index ¶
- func FindStoreCategoryName(id uuid.UUID, tx *gorm.DB) (name string)
- type ApiClient
- type AuthToken
- type Device
- type GroceryTrip
- type GroceryTripCategory
- type Item
- func (i *Item) AfterCreate(tx *gorm.DB) (err error)
- func (i *Item) AfterUpdate(tx *gorm.DB) (err error)
- func (i *Item) BeforeCreate(tx *gorm.DB) (err error)
- func (i *Item) BeforeSave(tx *gorm.DB) (err error)
- func (i *Item) BeforeUpdate(tx *gorm.DB) (err error)
- func (i *Item) CreateGroceryTripCategory(name string, tx *gorm.DB) (category GroceryTripCategory, err error)
- func (i *Item) DetermineCategoryName(storeID uuid.UUID, tx *gorm.DB) (result string, err error)
- func (i *Item) FetchGroceryTripCategory(name string, tx *gorm.DB) (category GroceryTripCategory, err error)
- type Meal
- type MealUser
- type Recipe
- type RecipeIngredient
- type Store
- type StoreCategory
- type StoreItemCategorySettings
- type StoreStapleItem
- type StoreUser
- type StoreUserPreference
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApiClient ¶
type ApiClient struct { ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` Name string `gorm:"type:varchar(100);uniqueIndex;not null"` Key string `gorm:"type:varchar(100);not null"` Secret string `gorm:"type:varchar(100);not null"` CreatedAt time.Time UpdatedAt time.Time // Associations Tokens []AuthToken `gorm:"foreignKey:ClientID"` }
type AuthToken ¶
type AuthToken struct { ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` ClientID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();not null"` UserID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();not null"` AccessToken string `gorm:"type:varchar(100);not null;index:idx_auth_tokens_access_token"` RefreshToken string `gorm:"type:varchar(100);not null"` ExpiresIn time.Time `gorm:"not null"` DeviceName string `gorm:"type:varchar(100)"` CreatedAt time.Time UpdatedAt time.Time // Associations Client ApiClient User User }
type GroceryTrip ¶
type GroceryTrip struct { ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` StoreID uuid.UUID `gorm:"type:uuid;not null;index"` Name string `gorm:"type:varchar(100);not null"` Completed bool `gorm:"default:false;not null"` CopyRemainingItems bool `gorm:"default:false;not null"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt // Associations Store Store Items []Item }
func (*GroceryTrip) BeforeCreate ¶
func (g *GroceryTrip) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate hook is triggered before a trip is created
type GroceryTripCategory ¶
type GroceryTripCategory struct { ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` GroceryTripID uuid.UUID `gorm:"type:uuid;not null;index:idx_grocery_trip_categories_grocery_trip_id"` StoreCategoryID uuid.UUID `gorm:"type:uuid;not null;index:idx_grocery_trip_categories_store_category_id"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt // Associations GroceryTrip GroceryTrip StoreCategory StoreCategory Item []Item `gorm:"foreignKey:CategoryID"` }
type Item ¶
type Item struct { ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` GroceryTripID uuid.UUID `gorm:"type:uuid;not null;index:idx_items_grocery_trip_id_name"` CategoryID *uuid.UUID `gorm:"type:uuid;not null"` UserID uuid.UUID `gorm:"type:uuid;not null"` StapleItemID *uuid.UUID `gorm:"type:uuid;index"` Name string `gorm:"type:varchar(100);not null;index:idx_items_grocery_trip_id_name"` Quantity int `gorm:"default:1;not null"` Completed *bool `gorm:"default:false;not null"` Position int `gorm:"default:1;not null"` Notes *string `gorm:"type:varchar(255)"` MealID *uuid.UUID `gorm:"type:uuid"` MealName *string `gorm:"type:varchar(255)"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt // Associations GroceryTrip GroceryTrip Meal Meal StapleItem StoreStapleItem }
Item defines the model for items
func (*Item) AfterCreate ¶
AfterCreate hook to touch the associated grocery trip after an item is created so that its UpdatedAt column is updated
func (*Item) BeforeCreate ¶
BeforeCreate hook updates the item position
func (*Item) BeforeUpdate ¶
BeforeUpdate hook handles reordering items
func (*Item) CreateGroceryTripCategory ¶
func (i *Item) CreateGroceryTripCategory(name string, tx *gorm.DB) (category GroceryTripCategory, err error)
CreateGroceryTripCategory creates a grocery trip category by name
func (*Item) DetermineCategoryName ¶
DetermineCategoryName first checks to see if this item's preferred category has been saved in the store settings and uses that if so. As a fallback, it opens the FoodClassification.json file and scans it
func (*Item) FetchGroceryTripCategory ¶
func (i *Item) FetchGroceryTripCategory(name string, tx *gorm.DB) (category GroceryTripCategory, err error)
FetchGroceryTripCategory retrieves a grocery trip category for a new item by finding or creating a category depending on if one exists by the name provided
type Meal ¶
type Meal struct { ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` RecipeID uuid.UUID `gorm:"type:uuid;not null"` UserID uuid.UUID `gorm:"type:uuid;not null"` StoreID uuid.UUID `gorm:"type:uuid;not null"` Name string `gorm:"type:varchar(255);not null;index:idx_meals_name"` MealType *string `gorm:"type:varchar(10)"` Servings int `gorm:"default:1;not null"` Notes *string `gorm:"type:text"` Date string `gorm:"type:varchar(255);not null;index:idx_meals_date"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt // Associations Users []MealUser Recipe Recipe User User }
Meal defines the model for meals A meal is a planned recipe for a user
type MealUser ¶
type MealUser struct { ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` MealID uuid.UUID `gorm:"type:uuid;not null"` UserID uuid.UUID `gorm:"type:uuid;not null;index:idx_meal_users_user_id"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt // Associations Meal Meal User User }
MealUser defines the model for meal_users, which represents a user's usage of a recipe
type Recipe ¶
type Recipe struct { ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` UserID uuid.UUID `gorm:"type:uuid;not null;index:idx_recipes_user_id"` Name string `gorm:"type:varchar(255);not null;index:idx_recipes_name"` Description *string `gorm:"type:text"` Instructions *datatypes.JSON `gorm:"type:json"` MealType *string `gorm:"type:varchar(10)"` URL *string `gorm:"type:varchar(255)"` ImageURL *string `gorm:"type:text"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt // Associations Ingredients []RecipeIngredient Meals []Meal }
Recipe defines the model for recipes
type RecipeIngredient ¶
type RecipeIngredient struct { ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` RecipeID uuid.UUID `gorm:"type:uuid;not null;index:idx_recipe_ingredients_recipe_id"` Name string `gorm:"type:varchar(255);not null"` Amount *string Unit *string `gorm:"type:varchar(20)"` Notes *string `gorm:"type:varchar(255);"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt // Associations Recipe Recipe }
RecipeIngredient defines the model for recipe_ingredients
type Store ¶
type Store struct { ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` UserID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();not null"` Name string `gorm:"type:varchar(100);not null"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt // Associations StoreUsers []StoreUser GroceryTrips []GroceryTrip }
func (*Store) AfterCreate ¶
AfterCreate hook to automatically create some associated records
func (*Store) AfterDelete ¶
AfterDelete hook handles deleting associated records after store is deleted
type StoreCategory ¶
type StoreCategory struct { ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` StoreID uuid.UUID `gorm:"type:uuid;not null;index:idx_store_categories_store_id"` Name string `gorm:"type:varchar(100);not null"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt // Associations Store Store }
type StoreStapleItem ¶
type StoreStapleItem struct { ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` StoreID uuid.UUID `gorm:"type:uuid;not null;index:idx_store_staple_items_store_id"` Name string `gorm:"type:varchar(100);not null"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt // Associations Store Store }
type StoreUser ¶
type StoreUser struct { ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` StoreID uuid.UUID `gorm:"type:uuid;not null;index:idx_store_users_store_id"` UserID uuid.UUID `gorm:"type:uuid"` Email string `gorm:"type:varchar(100)"` Creator *bool `gorm:"default:false;not null"` Active *bool `gorm:"default:true;not null"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt // Associations Preferences StoreUserPreference Store Store User User }
type StoreUserPreference ¶
type StoreUserPreference struct { ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` StoreUserID uuid.UUID `gorm:"type:uuid;uniqueIndex;not null"` DefaultStore bool `gorm:"default:false;not null"` Notifications bool `gorm:"default:true;not null"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt }
func (*StoreUserPreference) AfterUpdate ¶
func (sup *StoreUserPreference) AfterUpdate(tx *gorm.DB) (err error)
AfterUpdate hook handles some cleanup operations after updating store user prefs
type User ¶
type User struct { ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` Email string `gorm:"type:varchar(100);uniqueIndex;not null"` Password string `gorm:"not null"` Name string `gorm:"type:varchar(100)"` PasswordResetToken *uuid.UUID `gorm:"type:uuid"` PasswordResetTokenExpiry *time.Time SiwaID *string `gorm:"type:varchar(255);uniqueIndex"` LastSeenAt time.Time CreatedAt time.Time UpdatedAt time.Time // Associations Stores []Store Tokens []AuthToken }