Documentation ¶
Index ¶
- type Comments
- type Ingredient
- type MongoRecipeManager
- func (m *MongoRecipeManager) AddRecipe(recipe Recipe) (string, error)
- func (m *MongoRecipeManager) DeleteRecipe(id string) error
- func (m *MongoRecipeManager) GetAllRecipes() ([]Recipe, error)
- func (m *MongoRecipeManager) GetRecipeByID(id string) (Recipe, error)
- func (m *MongoRecipeManager) GetRecipesByTags(tags []string) ([]Recipe, error)
- func (m *MongoRecipeManager) GetTags() ([]string, error)
- func (m *MongoRecipeManager) SearchRecipes(query string, tags []string) ([]Recipe, error)
- func (m *MongoRecipeManager) UpdateRecipe(recipe Recipe) error
- type Recipe
- type RecipeManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ingredient ¶
func MergeIngredientQuantities ¶
func MergeIngredientQuantities(ingredients []Ingredient) (Ingredient, error)
MergeIngredientQuantities merges multiple ingredients of the same type together
func MergeIngredients ¶
func MergeIngredients(ingredients []Ingredient) []Ingredient
MergeIngredients takes a list of ingredients and merges any that are the same
type MongoRecipeManager ¶
type MongoRecipeManager struct {
// contains filtered or unexported fields
}
Define a MongoDB recipe manager that implements the RecipeManager interface
func CreateMongoRecipeManager ¶
func CreateMongoRecipeManager(uri, dbName, collectionName string) (*MongoRecipeManager, error)
CreateMongoRecipeManager creates a new MongoDB recipe manager
func (*MongoRecipeManager) AddRecipe ¶
func (m *MongoRecipeManager) AddRecipe(recipe Recipe) (string, error)
AddRecipe adds a recipe to the recipe manager and returns the ID of the new recipe
func (*MongoRecipeManager) DeleteRecipe ¶
func (m *MongoRecipeManager) DeleteRecipe(id string) error
DeleteRecipe deletes a recipe from the recipe manager
func (*MongoRecipeManager) GetAllRecipes ¶
func (m *MongoRecipeManager) GetAllRecipes() ([]Recipe, error)
GetAllRecipes returns all recipes in the recipe manager
func (*MongoRecipeManager) GetRecipeByID ¶
func (m *MongoRecipeManager) GetRecipeByID(id string) (Recipe, error)
GetRecipeByID returns a recipe with the given ID
func (*MongoRecipeManager) GetRecipesByTags ¶
func (m *MongoRecipeManager) GetRecipesByTags(tags []string) ([]Recipe, error)
GetRecipesByTags returns all recipes with the given tags
func (*MongoRecipeManager) GetTags ¶
func (m *MongoRecipeManager) GetTags() ([]string, error)
GetTags returns all tags in the recipe manager
func (*MongoRecipeManager) SearchRecipes ¶
func (m *MongoRecipeManager) SearchRecipes(query string, tags []string) ([]Recipe, error)
SearchRecipes returns all recipes that match the given query string and tags
func (*MongoRecipeManager) UpdateRecipe ¶
func (m *MongoRecipeManager) UpdateRecipe(recipe Recipe) error
UpdateRecipe updates a recipe in the recipe manager
type Recipe ¶
type Recipe struct { ID primitive.ObjectID `bson:"_id,omitempty"` Name string `bson:"name"` Description string `bson:"description"` Ingredients []Ingredient `bson:"ingredients"` Steps []string `bson:"steps"` Tags []string `bson:"tags"` Comments []Comments `bson:"comments"` }
func (*Recipe) AddTagToRecipe ¶
AddTagToRecipe adds a tag to a recipe if it is not already present
func (*Recipe) RemoveTagFromRecipe ¶
RemoveTagFromRecipe removes a tag from a recipe if it is present
type RecipeManager ¶
type RecipeManager interface { // AddRecipe adds a recipe to the recipe manager and returns the ID of the new recipe AddRecipe(recipe Recipe) (string, error) // DeleteRecipe deletes a recipe from the recipe manager DeleteRecipe(id string) error // UpdateRecipe updates a recipe in the recipe manager UpdateRecipe(recipe Recipe) error // GetAllRecipes returns all recipes in the recipe manager GetAllRecipes() ([]Recipe, error) // GetRecipeByID returns a recipe with the given ID GetRecipeByID(id string) (Recipe, error) // GetRecipesByTags returns all recipes with the given tags GetRecipesByTags(tags []string) ([]Recipe, error) // GetTags returns all tags in the recipe manager GetTags() ([]string, error) // SearchRecipes returns all recipes that match the given query string and tags SearchRecipes(query string, tags []string) ([]Recipe, error) }
Define an interface for a generic recipe manager