Documentation ¶
Index ¶
- func ConnnectionString(host, user, password, dbname string, port int64) string
- type BrandedFood
- type Client
- func (c *Client) AddIngredientUnit(ctx context.Context, m IngredientUnitMapping) error
- func (c *Client) AddRecipeToMeal(ctx context.Context, mealId, recipeId string, multiplier float64) error
- func (c *Client) AssignIds(ctx context.Context, r *RecipeDetail) error
- func (c *Client) AssociateFoodWithIngredient(ctx context.Context, ingredient string, fdcId int) error
- func (c *Client) FillFdcIdFromParentIfNcessary(ctx context.Context, i *Ingredient) error
- func (c *Client) FoodsByIds(ctx context.Context, ids []int) ([]Food, uint64, error)
- func (c *Client) GetAlbums(ctx context.Context) ([]GAlbum, error)
- func (c *Client) GetAllMeals(ctx context.Context) (Meals, error)
- func (c *Client) GetAllPhotos(ctx context.Context) (map[string]Photo, error)
- func (c *Client) GetBrandInfo(ctx context.Context, fdcID int) (*BrandedFood, error)
- func (c *Client) GetCategory(ctx context.Context, categoryID int64) (*FoodCategory, error)
- func (c *Client) GetFood(ctx context.Context, fdcID int) (*Food, error)
- func (c *Client) GetFoodNutrients(ctx context.Context, fdcID ...int) (FoodNutrients, error)
- func (c *Client) GetFoodPortions(ctx context.Context, fdcId ...int) (FoodPortions, error)
- func (c *Client) GetIngredientById(ctx context.Context, id string) (*Ingredient, error)
- func (c *Client) GetIngredientUnits(ctx context.Context, ingredient []string) (map[string][]IngredientUnitMapping, error)
- func (c *Client) GetIngredients(ctx context.Context, name string, ids []string, opts ...SearchOption) ([]Ingredient, uint64, error)
- func (c *Client) GetIngrientsSameAs(ctx context.Context, parent ...string) (Ingredients, uint64, error)
- func (c *Client) GetKV(ctx context.Context, key string) (string, error)
- func (c *Client) GetMealById(ctx context.Context, id string) (*Meal, error)
- func (c *Client) GetMealRecipes(ctx context.Context, mealID ...string) (MealRecipes, error)
- func (c *Client) GetNutrients(ctx context.Context, nutrientID ...int) (Nutrients, error)
- func (c *Client) GetPhotos(ctx context.Context) ([]Photo, error)
- func (c *Client) GetPhotosForMeal(ctx context.Context, meal string) ([]Photo, error)
- func (c *Client) GetRecipeDetailByIdFull(ctx context.Context, detailId string) (*RecipeDetail, error)
- func (c *Client) GetRecipeDetailSections(ctx context.Context, detailID string) ([]Section, error)
- func (c *Client) GetRecipeDetailWhere(ctx context.Context, eq sq.Sqlizer) (RecipeDetails, error)
- func (c *Client) GetRecipeDetailsWithIngredient(ctx context.Context, ingredient ...string) (RecipeDetails, error)
- func (c *Client) GetRecipes(ctx context.Context, searchQuery string, opts ...SearchOption) ([]Recipe, uint64, error)
- func (c *Client) GetRecipesDetails(ctx context.Context, searchQuery string, opts ...SearchOption) ([]RecipeDetail, uint64, error)
- func (c *Client) GetSectionIngredients(ctx context.Context, sectionId []string) (map[string][]SectionIngredient, error)
- func (c *Client) GetSectionInstructions(ctx context.Context, sectionId []string) (map[string][]SectionInstruction, error)
- func (c *Client) IngredientByName(ctx context.Context, name string) (*Ingredient, error)
- func (c *Client) IngredientToRecipe(ctx context.Context, ingredientID string) (*RecipeDetail, error)
- func (c *Client) InsertRecipe(ctx context.Context, r *RecipeDetail) (*RecipeDetail, error)
- func (c *Client) MergeIngredients(ctx context.Context, ingredientID string, ids []string) error
- func (c *Client) RecipeIngredientDependencies(ctx context.Context) ([]RecipeIngredientDependency, error)
- func (c *Client) SearchFoods(ctx context.Context, searchQuery string, dataType []string, ...) ([]Food, uint64, error)
- func (c *Client) SetKV(ctx context.Context, key string, json string) error
- func (c *Client) SyncMealsFromPhotos(ctx context.Context) error
- func (c *Client) UpsertPhotos(ctx context.Context, photos []Photo) error
- type Food
- type FoodCategory
- type FoodNutrient
- type FoodNutrients
- type FoodPortion
- type FoodPortions
- type Foods
- type GAlbum
- type Ingredient
- type IngredientUnitMapping
- type Ingredients
- type Meal
- type MealRecipe
- type MealRecipes
- type Meals
- type Nutrient
- type Nutrients
- type Photo
- type Recipe
- type RecipeDetail
- type RecipeDetails
- type RecipeIngredientDependency
- type SearchOption
- type SearchQuery
- type Section
- type SectionIngredient
- type SectionInstruction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnnectionString ¶
ConnnectionString returns a DSN.
Types ¶
type BrandedFood ¶
type BrandedFood struct { BrandOwner *string `db:"brand_owner"` Ingredients *string `db:"ingredients"` ServingSize float64 `db:"serving_size"` ServingSizeUnit string `db:"serving_size_unit"` HouseholdServing *string `db:"household_serving_fulltext"` BrandedFoodCategory *string `db:"branded_food_category"` }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a database client
func (*Client) AddIngredientUnit ¶
func (c *Client) AddIngredientUnit(ctx context.Context, m IngredientUnitMapping) error
func (*Client) AddRecipeToMeal ¶
func (*Client) AssignIds ¶
func (c *Client) AssignIds(ctx context.Context, r *RecipeDetail) error
AssignIds adds ids where missing.
func (*Client) AssociateFoodWithIngredient ¶
func (*Client) FillFdcIdFromParentIfNcessary ¶
func (c *Client) FillFdcIdFromParentIfNcessary(ctx context.Context, i *Ingredient) error
func (*Client) FoodsByIds ¶
func (*Client) GetAllPhotos ¶
func (*Client) GetBrandInfo ¶
func (*Client) GetCategory ¶
func (*Client) GetFoodNutrients ¶
func (*Client) GetFoodPortions ¶
func (*Client) GetIngredientById ¶
GetIngredientById finds an ingredient.
func (*Client) GetIngredientUnits ¶
func (*Client) GetIngredients ¶
func (c *Client) GetIngredients(ctx context.Context, name string, ids []string, opts ...SearchOption) ([]Ingredient, uint64, error)
GetIngredients returns all ingredients.
func (*Client) GetIngrientsSameAs ¶
func (*Client) GetMealById ¶
func (*Client) GetMealRecipes ¶
func (*Client) GetNutrients ¶
func (*Client) GetPhotosForMeal ¶
func (*Client) GetRecipeDetailByIdFull ¶
func (c *Client) GetRecipeDetailByIdFull(ctx context.Context, detailId string) (*RecipeDetail, error)
GetRecipeDetailByIdFull gets a recipe by Id, with all dependencies.
func (*Client) GetRecipeDetailSections ¶
GetRecipeDetailSections finds the sections.
func (*Client) GetRecipeDetailWhere ¶
GetRecipeById gets a recipe by name, shallowly.
func (*Client) GetRecipeDetailsWithIngredient ¶
func (c *Client) GetRecipeDetailsWithIngredient(ctx context.Context, ingredient ...string) (RecipeDetails, error)
GetRecipeDetailsWithIngredient gets all recipes with an ingredeitn todo: consolidate into getrecipes
func (*Client) GetRecipes ¶
func (*Client) GetRecipesDetails ¶
func (c *Client) GetRecipesDetails(ctx context.Context, searchQuery string, opts ...SearchOption) ([]RecipeDetail, uint64, error)
GetRecipes returns all recipes, shallowly.
func (*Client) GetSectionIngredients ¶
func (c *Client) GetSectionIngredients(ctx context.Context, sectionId []string) (map[string][]SectionIngredient, error)
GetSectionIngredients finds the ingredients for a section.
func (*Client) GetSectionInstructions ¶
func (c *Client) GetSectionInstructions(ctx context.Context, sectionId []string) (map[string][]SectionInstruction, error)
GetSectionInstructions finds the instructions for a section.
func (*Client) IngredientByName ¶
IngredientByName retrieves an ingredient by name, creating it if it does not exist.
func (*Client) IngredientToRecipe ¶
func (*Client) InsertRecipe ¶
func (c *Client) InsertRecipe(ctx context.Context, r *RecipeDetail) (*RecipeDetail, error)
InsertRecipe inserts a recipe.
func (*Client) MergeIngredients ¶
MergeIngredients sets the provided ingredients `same_as` to the first one. TODO: prevent cyclic loop?
func (*Client) RecipeIngredientDependencies ¶
func (c *Client) RecipeIngredientDependencies(ctx context.Context) ([]RecipeIngredientDependency, error)
func (*Client) SearchFoods ¶
func (*Client) SyncMealsFromPhotos ¶
type FoodCategory ¶
type FoodNutrient ¶
type FoodNutrients ¶
type FoodNutrients []FoodNutrient
type FoodPortion ¶
type FoodPortions ¶
type FoodPortions []FoodPortion
func (FoodPortions) ByFdcId ¶
func (r FoodPortions) ByFdcId() map[int][]FoodPortion
type Ingredient ¶
type Ingredient struct { Id string `json:"id"` Name string `json:"name"` FdcID zero.Int `db:"fdc_id"` SameAs zero.String `db:"same_as"` }
Ingredient is a globally-scoped ingredient
type IngredientUnitMapping ¶
type Ingredients ¶
type Ingredients []Ingredient
func (Ingredients) BySameAs ¶
func (r Ingredients) BySameAs() map[string][]Ingredient
func (Ingredients) IdsBySameAs ¶
func (r Ingredients) IdsBySameAs(id string) []string
type MealRecipe ¶
type MealRecipes ¶
type MealRecipes []MealRecipe
func (MealRecipes) ByMealID ¶
func (r MealRecipes) ByMealID() map[string][]MealRecipe
func (MealRecipes) RecipeIDs ¶
func (r MealRecipes) RecipeIDs() []string
type Recipe ¶
type Recipe struct { Id string `db:"id"` Detail RecipeDetail }
RecipeDetail represents a recipe
type RecipeDetail ¶
type RecipeDetail struct { Id string `db:"id"` RecipeId string `db:"recipe"` Name string `db:"name"` Equipment zero.String `db:"equipment"` Source zero.String `db:"source"` Servings zero.Int `db:"servings"` Quantity zero.Int `db:"quantity"` Unit zero.String `db:"unit"` Version int64 `db:"version"` LatestVersion bool `db:"is_latest_version"` Sections []Section Ingredient zero.String `db:"ingredient"` // sometimes, from FK }
RecipeDetail represents a recipe
type RecipeDetails ¶
type RecipeDetails []RecipeDetail
func (RecipeDetails) ByDetailId ¶
func (r RecipeDetails) ByDetailId() map[string]RecipeDetail
func (RecipeDetails) ByIngredientId ¶
func (r RecipeDetails) ByIngredientId() map[string][]RecipeDetail
func (RecipeDetails) ByRecipeId ¶
func (r RecipeDetails) ByRecipeId() map[string][]RecipeDetail
func (RecipeDetails) First ¶
func (r RecipeDetails) First() *RecipeDetail
type SearchOption ¶
type SearchOption func(*SearchQuery)
func WithLimit ¶
func WithLimit(limit uint64) SearchOption
func WithOffset ¶
func WithOffset(offset uint64) SearchOption
type SearchQuery ¶
type SearchQuery struct {
// contains filtered or unexported fields
}
type Section ¶
type Section struct { Id string `db:"id"` RecipeDetailId string `db:"recipe_detail"` TimeRange string `db:"duration_timerange"` Sort zero.Int `db:"sort"` Ingredients []SectionIngredient Instructions []SectionInstruction }
Section represents a Section
type SectionIngredient ¶
type SectionIngredient struct { Id string `db:"id"` SectionId string `db:"section"` Sort zero.Int `db:"sort"` Grams zero.Float `db:"grams"` Amount zero.Float `db:"amount"` Unit zero.String `db:"unit"` Adjective zero.String `db:"adjective"` Optional zero.Bool `db:"optional"` Original zero.String `db:"original"` SubsFor zero.String `db:"substitutes_for"` // one of the following is required for get and update: RecipeId zero.String `db:"recipe"` IngredientId zero.String `db:"ingredient"` // one of these is populated via gets RawRecipe *RecipeDetail RawIngredient *Ingredient }
SectionIngredient is a foo