blog

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DB_NAME           = "blog"
	POST_COL_NAME     = "posts"
	USER_COL_NAME     = "users"
	CATEGORY_COL_NAME = "categories"
)

Variables

View Source
var IncorrectErr = errors.New("Password Or Username Incorrect")

Functions

This section is empty.

Types

type BlogDB

type BlogDB struct {
	*models.DB
	// contains filtered or unexported fields
}

func NewBlogDB

func NewBlogDB(addr string) (db *BlogDB, err error)

func (*BlogDB) IsNameExists added in v0.3.0

func (t *BlogDB) IsNameExists(name string) (bool, error)

func (*BlogDB) LoadCategoryById added in v0.2.2

func (t *BlogDB) LoadCategoryById(cateid bson.ObjectId) (cate *Category, err error)

func (*BlogDB) LoadCategoryByName added in v0.2.2

func (t *BlogDB) LoadCategoryByName(name string) (cate *Category, err error)

func (*BlogDB) LoadPosts

func (t *BlogDB) LoadPosts(cfg *BlogPostCfg) (results []*Post, err error)

func (*BlogDB) LoadUserById

func (t *BlogDB) LoadUserById(uid bson.ObjectId) (user *User, err error)

func (*BlogDB) NewPost added in v0.3.0

func (t *BlogDB) NewPost(authorID bson.ObjectId, title, name, md string) (post *Post, err error)

NewPost insert new post

func (*BlogDB) UpdatePost added in v0.3.0

func (t *BlogDB) UpdatePost(user *User, name string, title string, md string, typeArg string) (p *Post, err error)

func (*BlogDB) ValidateLogin added in v0.3.0

func (t *BlogDB) ValidateLogin(account, password string) (u *User, err error)

type BlogPostCfg added in v0.2.2

type BlogPostCfg struct {
	Page, Size, Length          int
	Name, Tag, Regexp, Category string
}

type Category added in v0.2.2

type Category struct {
	ID   bson.ObjectId `bson:"_id" json:"mongo_id"`
	Name string        `bson:"name" json:"name"`
	URL  string        `bson:"url" json:"url"`
}

type Post

type Post struct {
	ID         bson.ObjectId `bson:"_id,omitempty" json:"mongo_id"`
	CreatedAt  time.Time     `bson:"post_created_at" json:"created_at"`
	ModifiedAt time.Time     `bson:"post_modified_gmt" json:"modified_at"`
	Title      string        `bson:"post_title" json:"title"`
	Type       string        `bson:"post_type" json:"type"`
	Status     string        `bson:"post_status" json:"status"`
	Name       string        `bson:"post_name" json:"name"`
	Content    string        `bson:"post_content" json:"content"`
	Markdown   string        `bson:"post_markdown" json:"markdown"`
	Author     bson.ObjectId `bson:"post_author" json:"author"`
	Password   string        `bson:"post_password", json:"password"`
	Category   bson.ObjectId `bson:"category,omitempty", json:"category"`
	Tags       []string      `bson:"post_tags", json:"tags"`
}

type User

type User struct {
	ID       bson.ObjectId `bson:"_id" json:"id"`
	Username string        `bson:"username" json:"username"`
	Account  string        `bson:"account" json:"account"`
	Password string        `bson:"password" json:"password"`
}

func (*User) GetID added in v0.3.2

func (u *User) GetID() string

func (*User) GetPayload added in v0.3.2

func (u *User) GetPayload() map[string]interface{}

Jump to

Keyboard shortcuts

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