models

package
v0.0.0-...-bde98bf Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseModel

type BaseModel struct {
	ID ModelID `gorm:"primary_key" json:"id"`
}

BaseModel is the base model for all models

func (*BaseModel) BeforeCreate

func (m *BaseModel) BeforeCreate()

BeforeCreate hook that creates a uuid for the model

type Category

type Category struct {
	BaseModel
	Name        string `gorm:"unique;not null" json:"name"`
	Description string `json:"description"`
}

Category is used to differentiate recipes

type Comment

type Comment struct {
	BaseModel
	Content   string
	UserID    ModelID
	User      User
	RecipeID  ModelID
	Recipe    Recipe
	CreatedAt time.Time
}

Comment defines a recipe comment

type Message

type Message struct {
	ID     string `json:"id"`
	Body   string `json:"body"`
	Sender string `json:"sender"`
}

type ModelID

type ModelID string

ModelID is the type of id used for the models

type Recipe

type Recipe struct {
	BaseModel
	Title        string    `gorm:"unique;not null" json:"title"`
	Description  string    `json:"description"`
	UsedProducts string    `validate:"required" json:"usedProducts"`
	Picture      string    `json:"picture"`
	CookingTime  int       `validate:"required" json:"cookingTime"`
	UserID       ModelID   `json:"userid"`
	User         User      `json:"user"`
	CategoryID   ModelID   `json:"categoryid"`
	Category     Category  `json:"category"`
	Comments     []Comment `json:"comments"`
	CreatedAt    time.Time `json:"createdAt"`
}

Recipe defines a cooking recipe

type Role

type Role struct {
	BaseModel
	Name string `gorm:"unique;not null"`
}

Role defines user roles

type User

type User struct {
	BaseModel
	Username string    `gorm:"unique;not null" json:"username"`
	Email    string    `gorm:"unique;not null" json:"email"`
	Password string    `gorm:"not null" json:"password"`
	Picture  string    `json:"picture"`
	RoleID   ModelID   `json:"roleid"`
	Role     Role      `json:"role"`
	Recipes  []Recipe  `json:"recipes"`
	Comments []Comment `json:"comments"`
}

User is application user

type UserResult

type UserResult struct {
	Username string `json:"username"`
	Picture  string `json:"picture"`
	Role     string `json:"userRole"`
	Token    string `json:"token"`
}

type UserToken

type UserToken struct {
	UserID   string `json:"userid"`
	Username string `json:"username"`
	Picture  string `json:"picture"`
	Role     string `json:"userRole"`
	jwt.StandardClaims
}

UserToken is user info in token

Jump to

Keyboard shortcuts

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