summaryrefslogtreecommitdiff
path: root/model/recipe.go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2024-01-17 21:37:52 +0100
committerxengineering <me@xengineering.eu>2024-01-18 19:52:29 +0100
commit325a2740e39b7c7937bfae8b76b092dd900fec9a (patch)
tree64587e601cf279458dd55fb90de0bacd202a2f1d /model/recipe.go
parent34fa1017a697287540d92d8c36ecca988f936f16 (diff)
downloadceres-325a2740e39b7c7937bfae8b76b092dd900fec9a.tar
ceres-325a2740e39b7c7937bfae8b76b092dd900fec9a.tar.zst
ceres-325a2740e39b7c7937bfae8b76b092dd900fec9a.zip
Show steps on recipe page
Diffstat (limited to 'model/recipe.go')
-rw-r--r--model/recipe.go26
1 files changed, 25 insertions, 1 deletions
diff --git a/model/recipe.go b/model/recipe.go
index 2b3953f..c6aa63c 100644
--- a/model/recipe.go
+++ b/model/recipe.go
@@ -6,6 +6,7 @@ type Recipe struct {
Portions string // FIXME has to be uint
URL string
Notes string
+ Steps []RecipeStep
}
func (d *Recipe) FromDB() error {
@@ -14,13 +15,36 @@ func (d *Recipe) FromDB() error {
return err
}
- return db.QueryRow(query, d.Id).Scan(
+ err = db.QueryRow(query, d.Id).Scan(
&d.Id,
&d.Title,
&d.Portions,
&d.URL,
&d.Notes,
)
+ if err != nil {
+ return err
+ }
+
+ query, err = GetSql(`steps-for-recipe`)
+ if err != nil {
+ return err
+ }
+
+ rows, err := db.Query(query, d.Id)
+ if err != nil {
+ return err
+ }
+ for rows.Next() {
+ var step RecipeStep
+ err = rows.Scan(&step.Text)
+ if err != nil {
+ return err
+ }
+ d.Steps = append(d.Steps, step)
+ }
+
+ return nil
}
func (d *Recipe) ToDB() error {