24 lines
756 B
Go
24 lines
756 B
Go
package models
|
|
|
|
// CurrentPlan represents the primary plan ID for a particular user ID.
|
|
type CurrentPlan struct {
|
|
UserID int64 `json:"user_id"`
|
|
PlanID int64 `json:"plan_id"`
|
|
}
|
|
|
|
// CurrentPlan returns the primary plan for a provided user ID in the given model.
|
|
func (m *Model) CurrentPlan(userID int) (*CurrentPlan, error) {
|
|
pp, err := m.SelectCurrentPlan(userID)
|
|
return pp, wrapNotFound(err)
|
|
}
|
|
|
|
// AddCurrentPlan inserts a given primary plan into the store, returning nothing.
|
|
func (m *Model) AddCurrentPlan(pp *CurrentPlan, userID int) error {
|
|
return m.InsertCurrentPlan(pp, userID)
|
|
}
|
|
|
|
// SaveCurrentPlan saves and updates a primary plan.
|
|
func (m *Model) SaveCurrentPlan(pp *CurrentPlan, userID int) error {
|
|
return m.UpdateCurrentPlan(pp, userID)
|
|
}
|