Documentation
¶
Index ¶
- Variables
- type Model
- type Note
- type NoteModel
- func (m *NoteModel) Create(note *Note) error
- func (m *NoteModel) CreateTx(note *Note, tx *sql.Tx) error
- func (m *NoteModel) Delete(id int64) error
- func (m *NoteModel) DeleteAll(recipeID int64) error
- func (m *NoteModel) DeleteAllTx(recipeID int64, tx *sql.Tx) error
- func (m *NoteModel) DeleteTx(id int64, tx *sql.Tx) error
- func (m *NoteModel) List(recipeID int64) (*Notes, error)
- func (m *NoteModel) Update(note *Note) error
- func (m *NoteModel) UpdateTx(note *Note, tx *sql.Tx) error
- type Notes
- type Recipe
- type RecipeImage
- type RecipeImageModel
- type RecipeImages
- type RecipeModel
- func (m *RecipeModel) Create(recipe *Recipe) error
- func (m *RecipeModel) CreateTx(recipe *Recipe, tx *sql.Tx) error
- func (m *RecipeModel) Delete(id int64) error
- func (m *RecipeModel) DeleteTx(id int64, tx *sql.Tx) error
- func (m *RecipeModel) Find(search string, page int64, count int64) (*Recipes, int64, error)
- func (m *RecipeModel) List(page int64, count int64) (*Recipes, int64, error)
- func (m *RecipeModel) Read(id int64) (*Recipe, error)
- func (m *RecipeModel) SetRating(id int64, rating float64) error
- func (m *RecipeModel) Update(recipe *Recipe) error
- func (m *RecipeModel) UpdateTx(recipe *Recipe, tx *sql.Tx) error
- type Recipes
- type TagModel
- func (m *TagModel) Create(recipeID int64, tag string) error
- func (m *TagModel) CreateTx(recipeID int64, tag string, tx *sql.Tx) error
- func (m *TagModel) DeleteAll(recipeID int64) error
- func (m *TagModel) DeleteAllTx(recipeID int64, tx *sql.Tx) error
- func (m *TagModel) List(recipeID int64) (*[]string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("No record found matching supplied criteria")
ErrNotFound represents the error when a database record cannot be found matching the criteria specified by the caller
Functions ¶
This section is empty.
Types ¶
type Model ¶ added in v0.3.0
type Model struct { Recipes *RecipeModel Tags *TagModel Notes *NoteModel Images *RecipeImageModel // contains filtered or unexported fields }
Model encapsulates the model layer of the application, including database access
type NoteModel ¶ added in v0.3.0
type NoteModel struct {
*Model
}
NoteModel provides functionality to edit and retrieve notes attached to recipes.
func (*NoteModel) Create ¶ added in v0.3.0
Create stores the note in the database as a new record using a dedicated transation that is committed if there are not errors.
func (*NoteModel) CreateTx ¶ added in v0.3.0
CreateTx stores the note in the database as a new record using the specified transaction.
func (*NoteModel) Delete ¶ added in v0.6.0
Delete removes the specified note from the database using a dedicated transation that is committed if there are not errors.
func (*NoteModel) DeleteAll ¶ added in v0.4.1
DeleteAll removes all notes for the specified recipe from the database using a dedicated transation that is committed if there are not errors.
func (*NoteModel) DeleteAllTx ¶ added in v0.4.1
DeleteAllTx removes all notes for the specified recipe from the database using the specified transaction.
func (*NoteModel) DeleteTx ¶ added in v0.6.0
DeleteTx removes the specified note from the database using the specified transaction.
func (*NoteModel) List ¶ added in v0.3.0
List retrieves all notes associated with the recipe with the specified id.
type Recipe ¶
type Recipe struct { ID int64 Name string ServingSize string NutritionInfo string Ingredients string Directions string AvgRating float64 Image string Tags []string }
Recipe is the primary model class for recipe storage and retrieval
type RecipeImage ¶
RecipeImage represents the data associated with an image attached to a recipe
type RecipeImageModel ¶ added in v0.3.0
type RecipeImageModel struct {
*Model
}
RecipeImageModel provides functionality to edit and retrieve images attached to recipes
func (*RecipeImageModel) Delete ¶ added in v0.6.0
func (m *RecipeImageModel) Delete(recipeID int64, name string) error
Delete deletes a single image attached to the specified recipe
func (*RecipeImageModel) DeleteAll ¶ added in v0.4.1
func (m *RecipeImageModel) DeleteAll(recipeID int64) error
DeleteAll deletes all the images attached to the specified recipe
func (*RecipeImageModel) List ¶ added in v0.3.0
func (m *RecipeImageModel) List(recipeID int64) (*RecipeImages, error)
List returns a RecipeImages slice that contains data for all images attached to the specified recipe
type RecipeImages ¶
type RecipeImages []RecipeImage
RecipeImages represents a collection of RecipeImage objects
type RecipeModel ¶ added in v0.3.0
type RecipeModel struct {
*Model
}
RecipeModel provides functionality to edit and retrieve recipes.
func (*RecipeModel) Create ¶ added in v0.3.0
func (m *RecipeModel) Create(recipe *Recipe) error
Create stores the recipe in the database as a new record using a dedicated transation that is committed if there are not errors.
func (*RecipeModel) CreateTx ¶ added in v0.3.0
func (m *RecipeModel) CreateTx(recipe *Recipe, tx *sql.Tx) error
CreateTx stores the recipe in the database as a new record using the specified transaction.
func (*RecipeModel) Delete ¶ added in v0.3.0
func (m *RecipeModel) Delete(id int64) error
Delete removes the specified recipe from the database using a dedicated transation that is committed if there are not errors. Note that this method does not delete any attachments that we associated with the deleted recipe.
func (*RecipeModel) DeleteTx ¶ added in v0.3.0
func (m *RecipeModel) DeleteTx(id int64, tx *sql.Tx) error
DeleteTx removes the specified recipe from the database using the specified transaction. Note that this method does not delete any attachments that we associated with the deleted recipe.
func (*RecipeModel) Find ¶ added in v0.3.0
Find retrieves all recipes matching the specified search string and within the range specified, sorted by name.
func (*RecipeModel) List ¶ added in v0.3.0
List retrieves all recipes within the range specified, sorted by name.
func (*RecipeModel) Read ¶ added in v0.3.0
func (m *RecipeModel) Read(id int64) (*Recipe, error)
Read retrieves the information about the recipe from the database, if found. If no recipe exists with the specified ID, a NoRecordFound error is returned.
func (*RecipeModel) SetRating ¶ added in v0.4.0
func (m *RecipeModel) SetRating(id int64, rating float64) error
SetRating adds or updates the rating of the specified recipe.
func (*RecipeModel) Update ¶ added in v0.3.0
func (m *RecipeModel) Update(recipe *Recipe) error
Update stores the specified recipe in the database by updating the existing record with the specified id using a dedicated transation that is committed if there are not errors.
type TagModel ¶ added in v0.3.0
type TagModel struct {
*Model
}
TagModel provides functionality to edit and retrieve tags attached to recipes.
func (*TagModel) Create ¶ added in v0.3.0
Create stores the tag in the database as a new record using a dedicated transation that is committed if there are not errors.
func (*TagModel) CreateTx ¶ added in v0.3.0
CreateTx stores the tag in the database as a new record using the specified transaction.
func (*TagModel) DeleteAll ¶ added in v0.3.0
DeleteAll removes all tags for the specified recipe from the database using a dedicated transation that is committed if there are not errors.
func (*TagModel) DeleteAllTx ¶ added in v0.3.0
DeleteAllTx removes all tags for the specified recipe from the database using the specified transaction.