From 0f951dcf029d4af284467543a3afdf5bf6581a20 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 23 Apr 2024 11:16:38 +0100 Subject: switched to Django --- internal/models/person.go | 51 ----------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 internal/models/person.go (limited to 'internal/models/person.go') diff --git a/internal/models/person.go b/internal/models/person.go deleted file mode 100644 index d2b8585..0000000 --- a/internal/models/person.go +++ /dev/null @@ -1,51 +0,0 @@ -package models - -import ( - "database/sql" - "time" -) - -type Person struct { - ID string - FirstName string - LastName string - OrganisationName string - OrganisationID int - RoleName string - Created time.Time -} - -type PersonModel struct { - DB *sql.DB -} - -func (m *PersonModel) ListAll() ([]Person, error) { - stmt := `SELECT p.id, p.first_name, p.last_name, p.role_name, org.name, org.id - FROM persons p - INNER JOIN organisations org ON p.organisation_id=org.id` - - rows, err := m.DB.Query(stmt) - if err != nil { - return nil, err - } - - defer rows.Close() - - var ps []Person - - for rows.Next() { - var p Person - err = rows.Scan(&p.ID, &p.FirstName, &p.LastName, &p.RoleName, &p.OrganisationName, &p.OrganisationID) - if err != nil { - return nil, err - } - - ps = append(ps, p) - } - - if err = rows.Err(); err != nil { - return nil, err - } - - return ps, err -} -- cgit v1.2.3