models

package
v0.0.0-...-0ae9f9e Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func InitializeDb

func InitializeDb(db *gorm.DB)

Types

type Categories

type Categories []Category

func (*Categories) Get

func (c *Categories) Get()

type Category

type Category struct {
	Model
	Name   string  `json:"name" binding:"required,max=100,min=2"`
	Status string  `json:"status" binding:"required"`
	Label  string  `json:"label" binding:"required"`
	Post   []*Post `gorm:"many2many:post_categories;"`
}

func (*Category) Create

func (c *Category) Create()

func (*Category) Delete

func (c *Category) Delete()

func (*Category) FindById

func (c *Category) FindById(id uint)

func (*Category) Update

func (c *Category) Update()

type Model

type Model struct {
	ID        uint      `json:"id" gorm:"primary_key"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type Post

type Post struct {
	Model
	Title       string      `json:"title" binding:"required,max=100,min=2"`
	Description string      `sql:"type:text;" json:"description" binding:"required,max=100,min=2"`
	OgType      string      `json:"og_type" binding:"required,max=100,min=2"`
	OgUrl       string      `json:"og_url" binding:"required,max=100,min=2"`
	Image       string      `json:"image"`
	Body        string      `sql:"type:text;" json:"body" binding:"required,min=2"`
	Category    []*Category `gorm:"many2many:post_categories;"`
	Profanity   bool        `json:"profanity" binding:"required"`
	UserId      string      `json:"user_id" binding:"required"`
	Status      string      `json:"status" binding:"required"`
}

func (*Post) AssignCategory

func (p *Post) AssignCategory(catIds []uint, update bool)

func (*Post) Create

func (p *Post) Create()

func (*Post) Delete

func (p *Post) Delete()

func (*Post) FindById

func (p *Post) FindById(id int64)

func (*Post) Update

func (p *Post) Update()

type PostCategories

type PostCategories []PostCategory

func (*PostCategories) GetByPostId

func (p *PostCategories) GetByPostId(id int64)

type PostCategory

type PostCategory struct {
	Model
	PostId     uint `json:"post_id" binding:"required"`
	CategoryId uint `json:"category_id" binding:"required"`
}

func (*PostCategory) Create

func (p *PostCategory) Create()

type Posts

type Posts []Post

func (*Posts) Get

func (p *Posts) Get()

type User

type User struct {
	Model
	Name     string `json:"name" binding:"required,max=100,min=2"`
	Email    string `json:"email" binding:"required,email,uniqueEmail" gorm:"type:varchar(200);unique_index"`
	Password string `json:"password" binding:"required,min=6,max=20"`
}

func (*User) Create

func (u *User) Create()

func (*User) FindByEmail

func (u *User) FindByEmail()

func (*User) FindById

func (u *User) FindById()

Jump to

Keyboard shortcuts

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