package models import ( "fmt" ) // Store represents the backing store. type Store interface { ConnectionLive() error SelectActions() ([]*Action, error) SelectActionByID(id int) (*Action, error) InsertAction(action *Action) (int, error) UpdateAction(action *Action) error SelectPlans() ([]*Plan, error) SelectPlanByID(id int) (*Plan, error) InsertPlan(plan *Plan) (int, error) SelectActionsByPlanID(plan *Plan) ([]*Action, error) SelectUserByUsername(username string) (*User, error) InsertUser(user *User) (int, error) } // Model represents a current model item. type Model struct { Store } // New creates an instance of the model using the passed in store. func New(store Store) *Model { return &Model{Store: store} } // Healthy returns an error if the connection is healthy. // Wrapper over db.Ping() func (m *Model) Healthy() error { if m.Store == nil { return fmt.Errorf("No store available") } return m.ConnectionLive() }