summaryrefslogtreecommitdiff
path: root/model/index.go
blob: cc7ffd555d06170307a9e995c426a566cbf48f94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
}