From f2a703ed9f5260b9df6693967ee86b68b78cb52f Mon Sep 17 00:00:00 2001 From: Nick Dumas Date: Sun, 2 Apr 2023 22:38:00 -0400 Subject: [PATCH] Return a map of areas because that makes more sense. --- models.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/models.go b/models.go index c382b1c..d187d55 100644 --- a/models.go +++ b/models.go @@ -22,8 +22,8 @@ type AardMapper struct { db *sql.DB } -func (am AardMapper) Areas() ([]Area, error) { - areas := make([]Area, 0) +func (am AardMapper) Areas() (map[string]Area, error) { + areas := make(map[string]Area) rows, err := am.db.Query("select uid, name, flags from areas;") if err != nil { @@ -33,7 +33,7 @@ func (am AardMapper) Areas() ([]Area, error) { for rows.Next() { var a Area err := rows.Scan(&a.Uid, &a.Name, &a.Flags) - areas = append(areas, a) + areas[a.Uid] = a if err != nil { return areas, fmt.Errorf("error scanning area into struct: %s\n", err) }