Add save function to pings
All checks were successful
Build and copy to prod / build-and-copy (push) Successful in 32s
All checks were successful
Build and copy to prod / build-and-copy (push) Successful in 32s
This commit is contained in:
parent
6d0f27eba7
commit
2561f492f9
@ -34,7 +34,7 @@ CREATE TABLE IF NOT EXISTS ping (
|
|||||||
);`
|
);`
|
||||||
|
|
||||||
const seedStatusQuery = `INSERT INTO statuses (id, name) VALUES (?, ?)
|
const seedStatusQuery = `INSERT INTO statuses (id, name) VALUES (?, ?)
|
||||||
ON CONFLICT (id) DO NOTHING`
|
ON CONFLICT (id) DO NOTHING;`
|
||||||
|
|
||||||
func CreateTable(db *sql.DB) {
|
func CreateTable(db *sql.DB) {
|
||||||
if _, err := db.Exec(createQuery); err != nil {
|
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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user