Documentation
¶
Index ¶
- Variables
- type Model
- type Note
- type NoteModel
- 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 }
type NoteModel ¶ added in v0.3.0
type NoteModel struct {
*Model
}
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.
type Recipe ¶
type Recipe struct { ID int64 Name string Description string Ingredients string Directions string AvgRating float64 Image string Tags []string }
Recipe is the primary model class for recipe storage and retrieval
type RecipeImage ¶
type RecipeImageModel ¶ added in v0.3.0
type RecipeImageModel struct {
*Model
}
func (*RecipeImageModel) List ¶ added in v0.3.0
func (m *RecipeImageModel) List(recipeID int64) (*RecipeImages, error)
type RecipeImages ¶
type RecipeImages []RecipeImage
type RecipeModel ¶ added in v0.3.0
type RecipeModel struct {
*Model
}
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
func (*RecipeModel) DeleteTx ¶ added in v0.3.0
func (m *RecipeModel) DeleteTx(id int64, tx *sql.Tx) error
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
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 sepcified id using a dedicated transation that is committed if there are not errors.