mealitem

package
v0.0.0-...-0f623ba Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicate    = errors.New("record already exists")
	ErrNotExists    = errors.New("row not exists")
	ErrUpdateFailed = errors.New("update failed")
	ErrDeleteFailed = errors.New("delete failed")
)

Functions

This section is empty.

Types

type MealItem

type MealItem struct {
	ID        int64
	Name      string
	Calories  int
	Carbs     int
	Fat       int
	Protein   int
	Nutrition *Nutrition
}

https://schema.org/Recipe

func NewMealItem

func NewMealItem(name string, calories, carbs, fat, protein float64) *MealItem

type Nutrition

type Nutrition struct {
	Calories            string // <Number> <Energy unit of measure>
	CarbohydrateContent string // <Number> <Mass unit of measure> -> in gram
	FatContent          string // <Number> <Mass unit of measure> -> in gram
	ProteinContent      string // <Number> <Mass unit of measure> -> in gram
}

https://schema.org/NutritionInformation

type Repository

type Repository interface {
	Migrate() error
	Create(mealitem MealItem) (*MealItem, error)
	All() ([]MealItem, error)
	GetByName(name string) (*MealItem, error)
	Update(id int64, updated MealItem) (*MealItem, error)
	Delete(id int64) error
}

type SQLiteRepository

type SQLiteRepository struct {
	// contains filtered or unexported fields
}

func NewSQLiteRepository

func NewSQLiteRepository(db *sql.DB) *SQLiteRepository

func (*SQLiteRepository) All

func (r *SQLiteRepository) All() ([]MealItem, error)

func (*SQLiteRepository) Create

func (r *SQLiteRepository) Create(mealitem MealItem) (*MealItem, error)

func (*SQLiteRepository) Delete

func (r *SQLiteRepository) Delete(id int64) error

func (*SQLiteRepository) GetByName

func (r *SQLiteRepository) GetByName(name string) (*MealItem, error)

func (*SQLiteRepository) Migrate

func (r *SQLiteRepository) Migrate() error

func (*SQLiteRepository) Update

func (r *SQLiteRepository) Update(id int64, updated MealItem) (*MealItem, error)

Jump to

Keyboard shortcuts

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