More output on the home page
Build and copy to prod / build-and-copy (push) Successful in 32s

This commit is contained in:
Lewis Dale committed 2024-05-13 07:37:11 +01:00
1 parent 72122553dd
commit a7a55b6a90
3 files changed
+61 -2

No files matched your search

+20 -1
View File
@@ -18,7 +18,7 @@ func CreateTable(db *sql.DB) {
}
type Site struct {
created_at uint64
Created_at string
Name string
Url string
}
@@ -32,3 +32,22 @@ SET
func (s *Site) Save(db *sql.DB) {
db.Exec(upsertQuery, s.Url, s.Name)
}
func List(db *sql.DB) []Site {
rows, err := db.Query(`SELECT url, name, created_at FROM sites ORDER BY created_at DESC`)
if err != nil {
panic(err)
}
defer rows.Close()
sites := make([]Site, 0)
for rows.Next() {
s := Site{}
rows.Scan(&s.Url, &s.Name, &s.Created_at)
sites = append(sites, s)
}
return sites
}