Closed rileycleavenger closed 1 year ago
Passing this issue on to @TylerMetz because he wants more experience with SQL databases
DevSchema.UserData
Database.go
SQLOpenDatabase()
SQLCloseDatabase()
StoreUserDatabase(u User)
- Use this as an example for new functions$ go get -u github.com/microsoft/go-mssqldb
@TylerMetz will redo all of the Database.go
functions, while removing all need for the Database struct
we defined
StorePublixDatabase(f []FoodItem)
ReadPublixDatabase() []FoodItem
ClearPublixDeals()
StoreWalmartDatabase(f []FoodItem)
ReadWalmartDatabase() []FoodItem
ClearWalmartDeals()
ReadUserDatabase(userName string) User
StoreUserPantry(u User)
InsertPantryItemPost (currUser User, f FoodItem)
UpdatePantry(currUser User, f []FoodItem)
GetUserPantry(userName string) Pantry
StorePubixScrapedTime(t time.Time)
ReadPublixScrapedTime() time.Time
StoreWalmartScrapedTime(t time.Time)
ReadWalmartScrapedTime() time.Time
WriteJSONRecipes()
DeleteJSONRecipes()
ReadJSONRecipes() []Recipe
WriteNewUserRecipe (currUser User, newRecipe Recipe)
DeleteUserRecipe (recipeID string)
ReadAllUserRecipes() []Recipe
ReadCurrUserRecipes (currUser User) []Recipe
FavoriteRecipe (currUser User, recipeID string)
UnfavoriteRecipe (currUser User, recipeID string)
ReadFavoriteRecipes (currUser User) []Recipe
getRecipeByID(db *sql.DB, recipeID string) (*Recipe, error)
getRecipeFromIdUserTable(db *sql.DB, recipeID string) (*Recipe, error)
getRecipeFromIdJSONTable(db *sql.DB, recipeID string) (*Recipe, error)
FindFavoriteRecipes(currUser User, routingRecipes []Recommendation) []Recommendation
GetUserPassword(username string) string
StoreCookie(username string, cookie string)
ReadCookie(username string) string
UserFromCookie(cookie string) User
ReadList(currUser User) List
WriteList(newItem FoodItem, currUser User)
UpdateListItem(newItem FoodItem, currUser User)
I updated all of the structs in the Backend to match the new tables (as seen in PR #444), here they are:
type FoodItem struct {
Name string `json:"Name"`
FoodType string `json:"FoodType"`
SaleDetails string `json:"SaleDetails"`
Quantity int `json:"Quantity"`
}
type GroceryStore struct {
Name string
ZipCode string
}
type List struct {
ShoppingList []FoodItem
}
type Pantry struct {
FoodInPantry []FoodItem
}
type Recipe struct {
Instructions string `json:"instructions"`
Ingredients []string `json:"ingredients"`
Title string `json:"title"`
PictureLink *string `json:"pictureLink"`
RecipeID string `json:"recipeID"`
UserFavorite bool `json:"userFavorite"`
}
type Scraper struct {
PublixDeals []FoodItem
WalmartDeals []FoodItem
}
type User struct{
FirstName string `json:"FirstName"`
LastName string `json:"LastName"`
Email string `json:"Email"`
UserName string `json:"UserName"`
Password string `json:"Password"`
UserPantry Pantry
UserList List
}
TO-DO:
Description
Need to create our SQL database on Azure and update Database.go. I think I can update the openDatabase() function and have it running correctly according to the example HERE.
Definition of Done
Database is hosted online and not locally