Documentation
¶
Index ¶
- Variables
- type FullIngredient
- type Ingredient
- type IngredientModel
- type IngredientModelInterface
- type Recipe
- type RecipeIngredient
- type RecipeIngredientModel
- type RecipeIngredientModelInterface
- type RecipeModel
- func (m *RecipeModel) Delete(id int) error
- func (m *RecipeModel) Get(id int) (*Recipe, error)
- func (m *RecipeModel) GetAll() ([]*Recipe, error)
- func (m *RecipeModel) GetWithTx(tx transactions.Transaction, id int) (*Recipe, error)
- func (m *RecipeModel) Insert(name, description, instructions, preparationTime, cookingTime string, ...) (int, error)
- func (m *RecipeModel) Ping() error
- func (m *RecipeModel) Update(recipe *Recipe) error
- type RecipeModelInterface
- type RecipeTag
- type RecipeTagModel
- type RecipeTagModelInterface
- type Tag
- type TagModel
- type TagModelInterface
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoRecord = errors.New("models: no matching record found")
Functions ¶
This section is empty.
Types ¶
type FullIngredient ¶ added in v1.1.0
type FullIngredient struct { *Ingredient Quantity float64 `json:"quantity"` Unit string `json:"unit"` }
FullIngredient abstracts away the two models for storing ingredients and their quantities/units
type Ingredient ¶ added in v1.1.0
type IngredientModel ¶ added in v1.1.0
func (*IngredientModel) GetByRecipeID ¶ added in v1.1.0
func (m *IngredientModel) GetByRecipeID(tx transactions.Transaction, recipeID int) ([]*FullIngredient, error)
func (*IngredientModel) InsertIfNotExists ¶ added in v1.1.0
func (m *IngredientModel) InsertIfNotExists(tx transactions.Transaction, name string) (int, error)
type IngredientModelInterface ¶ added in v1.1.0
type IngredientModelInterface interface { GetByRecipeID(tx transactions.Transaction, recipeID int) ([]*FullIngredient, error) InsertIfNotExists(tx transactions.Transaction, name string) (int, error) }
type Recipe ¶
type Recipe struct { ID int `json:"id"` Name string `json:"name"` Description string `json:"description,omitempty"` Instructions string `json:"instructions,omitempty"` PreparationTime string `json:"preparation_time,omitempty"` CookingTime string `json:"cooking_time,omitempty"` Portions int `json:"portions,omitempty"` CreatedAt time.Time `json:"-"` Ingredients []*FullIngredient `json:"ingredients,omitempty"` Tags []*Tag `json:"tags,omitempty"` }
type RecipeIngredient ¶ added in v1.1.0
type RecipeIngredientModel ¶ added in v1.1.0
func (*RecipeIngredientModel) Associate ¶ added in v1.1.0
func (m *RecipeIngredientModel) Associate(tx transactions.Transaction, recipeID, ingredientID int, quantity float64, unit string) error
func (*RecipeIngredientModel) DissociateNotInList ¶ added in v1.1.0
func (m *RecipeIngredientModel) DissociateNotInList(tx transactions.Transaction, recipeID int, recipeIngredients []*FullIngredient) error
type RecipeIngredientModelInterface ¶ added in v1.1.0
type RecipeIngredientModelInterface interface { Associate(tx transactions.Transaction, recipeID, ingredientID int, quantity float64, unit string) error DissociateNotInList(tx transactions.Transaction, recipeID int, recipeIngredients []*FullIngredient) error // contains filtered or unexported methods }
type RecipeModel ¶
type RecipeModel struct { DB *sql.DB IngredientModel IngredientModelInterface RecipeIngredientModel RecipeIngredientModelInterface TagModel TagModelInterface RecipeTagModel RecipeTagModelInterface }
func (*RecipeModel) Delete ¶
func (m *RecipeModel) Delete(id int) error
func (*RecipeModel) GetAll ¶ added in v1.1.0
func (m *RecipeModel) GetAll() ([]*Recipe, error)
func (*RecipeModel) GetWithTx ¶ added in v1.1.0
func (m *RecipeModel) GetWithTx(tx transactions.Transaction, id int) (*Recipe, error)
func (*RecipeModel) Insert ¶
func (m *RecipeModel) Insert(name, description, instructions, preparationTime, cookingTime string, portions int, ingredients []*FullIngredient, tags []*Tag) (int, error)
func (*RecipeModel) Ping ¶ added in v1.1.0
func (m *RecipeModel) Ping() error
func (*RecipeModel) Update ¶
func (m *RecipeModel) Update(recipe *Recipe) error
type RecipeModelInterface ¶ added in v1.1.0
type RecipeModelInterface interface { Ping() error Insert(name, description, instructions, preparationTime, cookingTime string, portions int, ingredients []*FullIngredient, tags []*Tag) (int, error) GetAll() ([]*Recipe, error) GetWithTx(tx transactions.Transaction, id int) (*Recipe, error) Get(id int) (*Recipe, error) Update(recipe *Recipe) error Delete(id int) error }
type RecipeTagModel ¶ added in v1.1.0
func (*RecipeTagModel) Associate ¶ added in v1.1.0
func (m *RecipeTagModel) Associate(tx transactions.Transaction, recipeID, tagID int) error
func (*RecipeTagModel) DissociateNotInList ¶ added in v1.1.0
func (m *RecipeTagModel) DissociateNotInList(tx transactions.Transaction, recipeID int, recipeTags []*Tag) error
type RecipeTagModelInterface ¶ added in v1.1.0
type RecipeTagModelInterface interface { Associate(tx transactions.Transaction, recipeID, tagID int) error DissociateNotInList(tx transactions.Transaction, recipeID int, recipeTags []*Tag) error // contains filtered or unexported methods }
type TagModel ¶ added in v1.1.0
func (*TagModel) GetByRecipeID ¶ added in v1.1.0
func (m *TagModel) GetByRecipeID(tx transactions.Transaction, recipeID int) ([]*Tag, error)
func (*TagModel) InsertIfNotExists ¶ added in v1.1.0
func (m *TagModel) InsertIfNotExists(tx transactions.Transaction, name string) (int, error)
type TagModelInterface ¶ added in v1.1.0
type TagModelInterface interface { GetByRecipeID(tx transactions.Transaction, recipeID int) ([]*Tag, error) InsertIfNotExists(tx transactions.Transaction, name string) (int, error) }
Click to show internal directories.
Click to hide internal directories.