model

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserTokenLength = 16
	MaxNameLength   = 32
)
View Source
const GlobalUsername = "default"

Variables

This section is empty.

Functions

func GenerateUserToken added in v0.13.3

func GenerateUserToken() string

Types

type Adjective

type Adjective struct {
	bun.BaseModel
	Name string `json:"name" bun:",pk"`
}

type ClassicalName

type ClassicalName struct {
	bun.BaseModel
	Name string `json:"name" bun:",pk"`
}

type Dough

type Dough struct {
	bun.BaseModel
	ID               int64  `bun:",pk"`
	Name             string `json:"name"`
	CaloriesPerSlice int    `json:"caloriesPerSlice"`
}

type Ingredient

type Ingredient struct {
	bun.BaseModel    `bun:"table:ingredients,alias:i"`
	ID               int64  `bun:",pk"`
	Name             string `json:"name"`
	CaloriesPerSlice int    `json:"caloriesPerSlice"`
	Vegetarian       bool   `json:"vegetarian"`
	Type             string `json:"-"`
}

type Pizza

type Pizza struct {
	ID          int64        `json:"id" bun:",pk,autoincrement"`
	CreatedAt   time.Time    `json:"-" bun:",nullzero,notnull,default:current_timestamp"`
	Name        string       `json:"name"`
	DoughID     int64        `json:"-"`
	Dough       Dough        `json:"dough" bun:"rel:belongs-to,join:dough_id=id"`
	Ingredients []Ingredient `json:"ingredients" bun:"m2m:pizza_to_ingredients,join:Pizza=Ingredient"`
	Tool        string       `json:"tool"`
}

func (Pizza) CalculateCalories

func (p Pizza) CalculateCalories() int

func (Pizza) IsVegetarian

func (p Pizza) IsVegetarian() bool

type PizzaToIngredients

type PizzaToIngredients struct {
	PizzaID      int64       `bun:",pk"`
	Pizza        *Pizza      `bun:"rel:belongs-to,join:pizza_id=id"`
	IngredientID int64       `bun:",pk"`
	Ingredient   *Ingredient `bun:"rel:belongs-to,join:ingredient_id=id"`
}

type Quote

type Quote struct {
	bun.BaseModel
	Name string `json:"name" bun:",pk"`
}

type Rating added in v0.13.3

type Rating struct {
	bun.BaseModel
	ID      int64  `json:"id" bun:",pk,autoincrement"`
	Stars   int    `json:"stars"`
	UserID  int64  `json:"-"`
	User    *User  `json:"-" bun:"rel:belongs-to,join:user_id=id"`
	PizzaID int64  `json:"pizza_id"`
	Pizza   *Pizza `json:"-" bun:"rel:belongs-to,join:pizza_id=id"`
}

func (*Rating) Validate added in v0.13.3

func (r *Rating) Validate() error

type Tool

type Tool struct {
	bun.BaseModel
	Name string `json:"name" bun:",pk"`
}

type User added in v0.13.3

type User struct {
	bun.BaseModel
	ID                int64  `json:"id" bun:",pk,autoincrement"`
	Username          string `json:"username" bun:",unique"`
	Token             string `json:"token,omitempty" bun:",unique"`
	Password          string `json:"password,omitempty" bun:"-"` // Only used for JSON
	PasswordHash      string `json:"-"`
	PasswordPlaintext string `json:"-"` // Only used for users created via testdata.yaml
}

func (*User) IsGlobal added in v0.13.4

func (u *User) IsGlobal() bool

func (*User) Validate added in v0.13.3

func (u *User) Validate() error

Jump to

Keyboard shortcuts

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