Documentation
¶
Index ¶
- func Connect() (*gorm.DB, error)
- func Migrate(db *gorm.DB) error
- type Ingredient
- type Ingredients
- type Recipe
- type RecipeRepo
- type RecipeSqlRepo
- func (r RecipeSqlRepo) Create(ctx context.Context, recipe *Recipe) error
- func (r RecipeSqlRepo) FindById(ctx context.Context, id any) (*Recipe, error)
- func (r RecipeSqlRepo) FindBySlug(ctx context.Context, slug string) (*Recipe, error)
- func (r RecipeSqlRepo) Update(ctx context.Context, recipe *Recipe) error
- type RecipeStep
- type RecipeSteps
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Ingredient ¶
type Ingredients ¶
type Ingredients map[string]Ingredient
type Recipe ¶
type Recipe struct {
juniper.Model
Slug string `gorm:"uniqueIndex"`
Title string
Description string `gorm:"type:text"`
Image string
PrepTime time.Duration
CookTime time.Duration
Ingredients Ingredients
Steps RecipeSteps
}
Recipe is the database model for recipes
type RecipeRepo ¶
type RecipeRepo interface {
FindById(ctx context.Context, id any) (*Recipe, error)
FindBySlug(ctx context.Context, slug string) (*Recipe, error)
Create(ctx context.Context, recipe *Recipe) error
Update(ctx context.Context, recipe *Recipe) error
}
func NewRecipeSqlRepo ¶
func NewRecipeSqlRepo(fallbackDB *gorm.DB) RecipeRepo
NewRecipeSqlRepo creates a new instance of the RecipeSqlRepo struct
type RecipeSqlRepo ¶
type RecipeSqlRepo struct {
// contains filtered or unexported fields
}
func (RecipeSqlRepo) Create ¶
func (r RecipeSqlRepo) Create(ctx context.Context, recipe *Recipe) error
Create adds a new recipe to the database
func (RecipeSqlRepo) FindBySlug ¶
FindBySlug finds a recipe by its unique slug
type RecipeSteps ¶
type RecipeSteps []RecipeStep
Click to show internal directories.
Click to hide internal directories.