diff options
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 +} |