models

package
v0.0.0-...-ee70201 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPost

func AddPost(data map[string]interface{}) error

func CloseDB

func CloseDB()

func InitDB

func InitDB() error

func PostCount

func PostCount() (int, error)

Types

type Post

type Post struct {
	gorm.Model
	Title   string `gorm:"type:varchar(100);unique;not null"`
	Content string `gorm:'type:text;`
	Tags    []*Tag `gorm:"many2many:post_tag"`
}

func GetPost

func GetPost(id string) (*Post, error)

func GetPosts

func GetPosts(pageNum int, pageSize int) ([]*Post, error)

func (*Post) DeletePost

func (p *Post) DeletePost() error

func (*Post) UpdatePost

func (p *Post) UpdatePost() error

type Tag

type Tag struct {
	gorm.Model
	Name  string  `gorm:"type:varchar(100);unique;not null"`
	Posts []*Post `gorm:"many2many:post_tag"`
}

func CreateTagByName

func CreateTagByName(name string) (*Tag, error)

func GenerateTag

func GenerateTag(name string) (*Tag, error)

func GetTag

func GetTag(id interface{}) (*Tag, error)

func GetTagByName

func GetTagByName(name string) (*Tag, error)

func GetTags

func GetTags() ([]*Tag, error)

Jump to

Keyboard shortcuts

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