foodstorage

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeNutrientsFromBase

func ComputeNutrientsFromBase(
	ref FoodRef,
	quantity float64,
) map[string]Nutrient

func SaveEntries

func SaveEntries(entries []FoodEntry) error

func SaveFoodRefs

func SaveFoodRefs(foods []FoodRef) error

Types

type FoodEntry

type FoodEntry struct {
	ID        int                 `json:"id"`
	FoodID    int                 `json:"foodId"`
	Name      string              `json:"name"`
	Quantity  float64             `json:"quantity"` // ex: 30
	Unit      string              `json:"unit"`     // g ou ml
	Meal      int                 `json:"meal"`
	Date      string              `json:"date"`
	Nutrients map[string]Nutrient `json:"nutrients"` // calculés
}

func ReadEntries

func ReadEntries() ([]FoodEntry, error)

type FoodRef

type FoodRef struct {
	ID        int                 `json:"id"`
	Name      string              `json:"name"`
	BaseQty   float64             `json:"baseQty"`   // 100
	BaseUnit  string              `json:"baseUnit"`  // "g" ou "ml"
	Nutrients map[string]Nutrient `json:"nutrients"` // POUR baseQty
}

func ReadFoodRefs

func ReadFoodRefs() ([]FoodRef, error)

type Nutrient

type Nutrient struct {
	Value float64 `json:"value"`
	Unit  string  `json:"unit"`
}

Jump to

Keyboard shortcuts

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