diff options
author | xengineering <me@xengineering.eu> | 2024-01-08 19:27:47 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2024-01-08 19:33:24 +0100 |
commit | 43e7bb10eaade56a9444ec089aa3102218231868 (patch) | |
tree | 259e52b1978cfdf7ff979b0614c545d24d957c88 /model/recipe.go | |
parent | c6d2e9dadcd08cdf82aab507d9d4d8d58574df20 (diff) | |
download | ceres-43e7bb10eaade56a9444ec089aa3102218231868.tar ceres-43e7bb10eaade56a9444ec089aa3102218231868.tar.zst ceres-43e7bb10eaade56a9444ec089aa3102218231868.zip |
Implement recipe page
Diffstat (limited to 'model/recipe.go')
-rw-r--r-- | model/recipe.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/model/recipe.go b/model/recipe.go new file mode 100644 index 0000000..2b3953f --- /dev/null +++ b/model/recipe.go @@ -0,0 +1,35 @@ +package model + +type Recipe struct { + Id string // FIXME has to be uint + Title string + Portions string // FIXME has to be uint + URL string + Notes string +} + +func (d *Recipe) FromDB() error { + query, err := GetSql(`recipe-select`) + if err != nil { + return err + } + + return db.QueryRow(query, d.Id).Scan( + &d.Id, + &d.Title, + &d.Portions, + &d.URL, + &d.Notes, + ) +} + +func (d *Recipe) ToDB() error { + query, err := GetSql(`recipe-update`) + if err != nil { + return err + } + + _, err = db.Exec(query, d.Title, d.Portions, d.URL, d.Notes, d.Id) + + return err +} |