model

package
v0.0.0-...-155fe22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteGoal

func DeleteGoal(db *sqlx.DB, id string) error

DeleteGoal deletes a goal from the database.

func DeleteProgress

func DeleteProgress(db *sqlx.DB, id string) error

DeleteProgress deletes a progress from the database.

func DeleteSystem

func DeleteSystem(db *sqlx.DB, id string) error

DeleteSystem deletes a system from the database.

Types

type Goal

type Goal struct {
	ID          string    `db:"goal_id" json:"goal_id"`
	Name        string    `db:"name" json:"name"`
	Context     string    `db:"context" json:"context"`
	DateCreated time.Time `db:"date_created" json:"date_created"`
}

Goal represents a row in goal database table.

func CreateGoal

func CreateGoal(db *sqlx.DB, n *NewGoal) (*Goal, error)

CreateGoal creates a goal in the database.

func GetGoal

func GetGoal(db *sqlx.DB, id string) (*Goal, error)

GetGoal retrieves a goal from the database.

func GetGoals

func GetGoals(db *sqlx.DB) ([]Goal, error)

GetGoals retrieves all goals from the database.

func UpdateGoal

func UpdateGoal(db *sqlx.DB, id string, u *UpdatedGoal) (*Goal, error)

UpdateGoal updates a goal from the database.

type Health

type Health struct {
	Status string `json:"status"`
}

Health represents a health information.

func GetHealth

func GetHealth(db *sqlx.DB) (*Health, error)

GetHealth gets health information for the database.

type NewGoal

type NewGoal struct {
	Name    string `json:"name" validate:"required"`
	Context string `json:"context"`
}

NewGoal is what required to create a new goal.

type NewProgress

type NewProgress struct {
	SystemID       string    `json:"system_id" validate:"required"`
	Context        string    `json:"context"`
	Completed      bool      `json:"completed" validate:"required"`
	MeasurableData int       `json:"measurable_data"`
	MeasurableUnit string    `json:"measurable_unit"`
	Sets           int       `json:"sets"`
	Reps           int       `json:"reps"`
	Link           string    `json:"link"`
	DateCreated    time.Time `json:"date_created"`
}

NewProgress is what required to create a new progress.

type NewSystem

type NewSystem struct {
	GoalID string `json:"goal_id" validate:"required"`
	Name   string `json:"name" validate:"required"`
	Repeat string `json:"repeat"`
}

NewSystem is what required to create a new system.

type Progress

type Progress struct {
	ID             string    `db:"progress_id" json:"progress_id"`
	SystemID       string    `db:"system_id" json:"system_id"`
	Context        string    `db:"context" json:"context"`
	Completed      bool      `db:"completed" json:"completed"`
	MeasurableData int       `db:"measurable_data" json:"measurable_data"`
	MeasurableUnit string    `db:"measurable_unit" json:"measurable_unit"`
	Sets           int       `db:"sets" json:"sets"`
	Reps           int       `db:"reps" json:"reps"`
	Link           string    `db:"link" json:"link"`
	DateCreated    time.Time `db:"date_created" json:"date_created"`
}

Progress represents a row in progress database table.

func CreateProgress

func CreateProgress(db *sqlx.DB, n *NewProgress) (*Progress, error)

CreateProgress creates a progress in the database.

func GetProgress

func GetProgress(db *sqlx.DB, id string) (*Progress, error)

GetProgress retrieves a progress from the database.

func GetProgresses

func GetProgresses(db *sqlx.DB) ([]Progress, error)

GetProgresses retrieves all progress from the database.

func UpdateProgress

func UpdateProgress(db *sqlx.DB, id string, u *UpdatedProgress) (*Progress, error)

UpdateProgress updates a progress from the database.

type System

type System struct {
	ID          string    `db:"system_id" json:"system_id"`
	GoalID      string    `db:"goal_id" json:"goal_id"`
	Name        string    `db:"name" json:"name"`
	Repeat      string    `db:"repeat" json:"repeat"`
	DateCreated time.Time `db:"date_created" json:"date_created"`
}

System represents a row in system database table.

func CreateSystem

func CreateSystem(db *sqlx.DB, n *NewSystem) (*System, error)

CreateSystem creates a system in the database.

func GetSystem

func GetSystem(db *sqlx.DB, id string) (*System, error)

GetSystem retrieves a system from the database.

func GetSystems

func GetSystems(db *sqlx.DB) ([]System, error)

GetSystems retrieves all systems from the database.

func UpdateSystem

func UpdateSystem(db *sqlx.DB, id string, u *UpdatedSystem) (*System, error)

UpdateSystem updates a system from the database.

type UpdatedGoal

type UpdatedGoal struct {
	Name    string `json:"name" validate:"required_without=Context"`
	Context string `json:"context" validate:"required_without=Name"`
}

UpdatedGoal is what required to update a goal.

type UpdatedProgress

type UpdatedProgress struct {
	Context        string    `json:"context" validate:"required_without=Completed MeasurableData MeasurableUnit Sets Reps Link DateCreated"`
	Completed      bool      `json:"completed" validate:"required_without=Context MeasurableData MeasurableUnit Sets Reps Link DateCreated"`
	MeasurableData int       `json:"measurable_data" validate:"required_without=Context Completed MeasurableUnit Sets Reps Link DateCreated"`
	MeasurableUnit string    `json:"measurable_unit" validate:"required_without=Context Completed MeasurableData Sets Reps Link DateCreated"`
	Sets           int       `json:"sets" validate:"required_without=Context Completed MeasurableData MeasurableUnit Reps Link DateCreated"`
	Reps           int       `json:"reps" validate:"required_without=Context Completed MeasurableData MeasurableUnit Sets Link DateCreated"`
	Link           string    `json:"link" validate:"required_without=Context Completed MeasurableData MeasurableUnit Sets Reps DateCreated"`
	DateCreated    time.Time `json:"date_created" validate:"required_without=Context Completed MeasurableData MeasurableUnit Sets Reps Link"`
}

UpdatedProgress is what required to update a progress.

type UpdatedSystem

type UpdatedSystem struct {
	Name   string `json:"name" validate:"required_without=Repeat"`
	Repeat string `json:"repeat" validate:"required_without=Name"`
}

UpdatedSystem is what required to update a system.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL