1
0
Fork 0
empact/db/task.go

40 lines
609 B
Go
Raw Normal View History

2015-03-04 20:51:17 +00:00
package db
import (
"time"
)
type (
Task struct {
Token string
Owner string
Job string
Worker string
Duration int64
Error string
CreatedAt time.Time
StartedAt time.Time
}
)
const (
saveTaskQuery = "" +
"insert into tasks (token, owner, job, worker, duration, error, created_at, started_at) " +
"values (?, ?, ?, ?, ?, ?, ?, ?)"
)
func (t *Task) Save() {
2015-03-05 12:54:05 +00:00
if _, err := stmt(saveTaskQuery).Exec(
t.Token, t.Owner,
t.Job, t.Worker,
t.Duration, t.Error,
t.CreatedAt, t.StartedAt,
); err != nil {
2015-03-04 20:51:17 +00:00
panic(err)
}
}
2015-03-05 12:54:05 +00:00
func (t *Task) T() *Task {
return t
}