From 34fa1017a697287540d92d8c36ecca988f936f16 Mon Sep 17 00:00:00 2001
From: xengineering <me@xengineering.eu>
Date: Wed, 17 Jan 2024 20:56:33 +0100
Subject: Add recipe step view

This is the next increment to implement recipe steps.
---
 model/recipe_step.go             | 33 +++++++++++++++++++++++++++++++++
 model/sql/recipe-step-select.sql |  2 ++
 2 files changed, 35 insertions(+)
 create mode 100644 model/recipe_step.go
 create mode 100644 model/sql/recipe-step-select.sql

(limited to 'model')

diff --git a/model/recipe_step.go b/model/recipe_step.go
new file mode 100644
index 0000000..980d312
--- /dev/null
+++ b/model/recipe_step.go
@@ -0,0 +1,33 @@
+package model
+
+import (
+	"log"
+)
+
+type RecipeStep struct {
+	Id       string  // FIXME has to be uint
+	RecipeId string  // FIXME has to be uint
+	Index    string  // FIXME has to be uint
+	Text     string
+}
+
+func (d *RecipeStep) String() string {
+	return d.Text
+}
+
+func (d *RecipeStep) FromDB() error {
+	query, err := GetSql(`recipe-step-select`)
+	if err != nil {
+		return err
+	}
+
+	err = db.QueryRow(query, d.Id).Scan(
+		&d.Id,
+		&d.RecipeId,
+		&d.Index,
+		&d.Text,
+	)
+
+	log.Printf("d.Text: %s %s %s %s\n", d.Id, d.RecipeId, d.Index, d.Text)
+	return err
+}
diff --git a/model/sql/recipe-step-select.sql b/model/sql/recipe-step-select.sql
new file mode 100644
index 0000000..0aba980
--- /dev/null
+++ b/model/sql/recipe-step-select.sql
@@ -0,0 +1,2 @@
+SELECT id,recipe_id,"index",text FROM recipe_steps
+WHERE id=?;
-- 
cgit v1.2.3-70-g09d2