diff options
Diffstat (limited to 'model/recipe.go')
-rw-r--r-- | model/recipe.go | 26 |
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 { |