Add save function to pings
Build and copy to prod / build-and-copy (push) Successful in 32s Details

This commit is contained in:
Lewis Dale 2024-05-09 08:04:25 +01:00
parent 6d0f27eba7
commit 2561f492f9
1 changed files with 4 additions and 2 deletions

View File

@ -34,7 +34,7 @@ CREATE TABLE IF NOT EXISTS ping (
);`
const seedStatusQuery = `INSERT INTO statuses (id, name) VALUES (?, ?)
ON CONFLICT (id) DO NOTHING`
ON CONFLICT (id) DO NOTHING;`
func CreateTable(db *sql.DB) {
if _, err := db.Exec(createQuery); err != nil {
@ -53,6 +53,8 @@ func seedStatuses(db *sql.DB) {
}
}
func (p *Ping) Save(db *sql.DB) {
const saveQuery = `INSERT INTO ping (site, status) VALUES (?, ?);`
func (p *Ping) Save(db *sql.DB) {
db.Exec(saveQuery, p.Site.Url, p.Status)
}