diff options
Diffstat (limited to 'model/recipe.go')
-rw-r--r-- | model/recipe.go | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/model/recipe.go b/model/recipe.go index fc2ae3a..684b158 100644 --- a/model/recipe.go +++ b/model/recipe.go @@ -16,6 +16,7 @@ type Recipe struct { Created string `json:"created"` LastChanged string `json:"last_changed"` Steps []Step `json:"steps"` + IsFavorite bool `json:"is_favorite"` } func (r Recipe) String() string { @@ -69,13 +70,13 @@ func (r *Recipe) Create(tx *sql.Tx) error { cmd := ` INSERT INTO recipes - (title, portions, url, notes, created, last_changed) + (title, portions, url, notes, created, last_changed, is_favorite) VALUES - (?, ?, ?, ?, ?, ?) + (?, ?, ?, ?, ?, ?, ?) ` result, err := tx.Exec(cmd, r.Title, r.Portions, r.Url, r.Notes, r.Created, - r.LastChanged) + r.LastChanged, r.IsFavorite) if err != nil { return err } @@ -136,7 +137,7 @@ ORDER BY func (r *Recipe) Read(tx *sql.Tx) error { cmd := ` SELECT - title, portions, url, notes, created, last_changed + title, portions, url, notes, created, last_changed, is_favorite FROM recipes WHERE @@ -160,6 +161,7 @@ WHERE &r.Notes, &r.Created, &r.LastChanged, + &r.IsFavorite, ) if err != nil { return err @@ -216,12 +218,13 @@ SET url = ?, notes = ?, created = ?, - last_changed = ? + last_changed = ?, + is_favorite = ? WHERE id = ?` res, err := tx.Exec(cmd, r.Title, r.Portions, r.Url, r.Notes, r.Created, - r.LastChanged, r.Id) + r.LastChanged, r.IsFavorite, r.Id) if err != nil { return err } @@ -296,6 +299,7 @@ func RecipeTestData() []Recipe { }, }, }, + IsFavorite: true, }, { Title: "Burger", @@ -305,6 +309,7 @@ func RecipeTestData() []Recipe { Created: "1715658069", LastChanged: "1715958070", Steps: []Step{}, + IsFavorite: false, }, } } |