2020-03-04 10:29:00 +00:00
|
|
|
package hits
|
|
|
|
|
2020-03-04 14:20:47 +00:00
|
|
|
import (
|
2020-03-09 18:17:55 +00:00
|
|
|
"github.com/statping/statping/database"
|
|
|
|
"github.com/statping/statping/utils"
|
2020-03-04 14:20:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var log = utils.Log
|
2020-03-04 10:29:00 +00:00
|
|
|
|
2020-03-10 05:24:35 +00:00
|
|
|
var db database.Database
|
|
|
|
|
|
|
|
func SetDB(database database.Database) {
|
|
|
|
db = database.Model(&Hit{})
|
2020-03-04 10:29:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Hit) Create() error {
|
2020-03-10 05:24:35 +00:00
|
|
|
q := db.Create(h)
|
|
|
|
return q.Error()
|
2020-03-04 10:29:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Hit) Update() error {
|
2020-03-10 05:24:35 +00:00
|
|
|
q := db.Update(h)
|
|
|
|
return q.Error()
|
2020-03-04 10:29:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Hit) Delete() error {
|
2020-03-10 05:24:35 +00:00
|
|
|
q := db.Delete(h)
|
|
|
|
return q.Error()
|
2020-03-04 10:29:00 +00:00
|
|
|
}
|