diff options
author | xengineering <me@xengineering.eu> | 2023-12-27 13:33:59 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-12-27 13:33:59 +0100 |
commit | c6d2e9dadcd08cdf82aab507d9d4d8d58574df20 (patch) | |
tree | 65495b3fd84060638c5dc396417b6aab926bca79 /model/index.go | |
parent | 1978c5257e2cf4720716b59c3d69dc21cf457c18 (diff) | |
download | ceres-c6d2e9dadcd08cdf82aab507d9d4d8d58574df20.tar ceres-c6d2e9dadcd08cdf82aab507d9d4d8d58574df20.tar.zst ceres-c6d2e9dadcd08cdf82aab507d9d4d8d58574df20.zip |
Implement index page with recipe overview
Diffstat (limited to 'model/index.go')
-rw-r--r-- | model/index.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/model/index.go b/model/index.go new file mode 100644 index 0000000..cc7ffd5 --- /dev/null +++ b/model/index.go @@ -0,0 +1,29 @@ +package model + +type IndexElement struct { + Id uint + Title string +} + +type Index []IndexElement + +func (d *Index) FromDB() error { + query, err := GetSql(`index-select`) + if err != nil { + return err + } + rows, err := db.Query(query) + if err != nil { + return err + } + + for rows.Next() { + var i IndexElement + if err = rows.Scan(&i.Id, &i.Title); err != nil { + return err + } + *d = append(*d, i) + } + + return nil +} |